ZQuest Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2025-07-30 06:57:43
Exec Total Coverage
Lines: 9204 12204 75.4%
Functions: 378 436 86.7%
Branches: 7303 12920 56.5%

Line Branch Exec Source
1 #include "base/handles.h"
2 #include "base/zdefs.h"
3 #include <cstring>
4 #include <optional>
5 #include <stdio.h>
6 #include "base/combo.h"
7 #include "base/general.h"
8 #include "base/zc_alleg.h"
9 #include "zc/guys.h"
10 #include "zc/replay.h"
11 #include "zc/zc_ffc.h"
12 #include "zc/zc_subscr.h"
13 #include "zc/zelda.h"
14 #include "base/zsys.h"
15 #include "base/msgstr.h"
16 #include "zc/maps.h"
17 #include "zc/hero.h"
18 #include "subscr.h"
19 #include "zc/ffscript.h"
20 #include "gamedata.h"
21 #include "defdata.h"
22 #include "zscriptversion.h"
23 #include "particles.h"
24 #include "base/zc_math.h"
25 #include "slopes.h"
26 #include "base/qrs.h"
27 #include "base/dmap.h"
28 #include "base/mapscr.h"
29 #include "base/misctypes.h"
30 #include "base/initdata.h"
31 #include "zc/combos.h"
32 #include "iter.h"
33
34 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
35
36 int32_t repaircharge=0;
37 bool adjustmagic=false;
38 bool learnslash=false;
39 int32_t wallm_load_clk=0;
40 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
41 int32_t vhead=0;
42
43 char *guy_string[eMAXGUYS];
44
45 void playLevelMusic();
46
47 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
48 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
49
50 1109663 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
51 {
52 1109663 int32_t c = coord.getInt();
53
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1109386 times.
1109663 if(nearest_half)
54 {
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1109386 times.
1109386 if (c < 0)
56 c -= val / 2;
57 1109386 else c += (val/2);
58 1109386 }
59 1109663 c -= c % val;
60 1109663 coord = c;
61 1109663 }
62
63 38401026 static bool OUTOFBOUNDS(int32_t id, int32_t x, int32_t y)
64 {
65
4/4
✓ Branch 0 taken 37884420 times.
✓ Branch 1 taken 516606 times.
✓ Branch 2 taken 1215 times.
✓ Branch 3 taken 38399811 times.
38401026 if (y > world_h + (isSideViewGravity() && canfall(id) ? 16 : 176)) return true;
66
2/2
✓ Branch 0 taken 30320 times.
✓ Branch 1 taken 38369491 times.
38399811 if (y < -176) return true;
67
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38369491 times.
38369491 if (x < -256) return true;
68
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 38369425 times.
38369491 if (x > world_w+256) return true;
69 38369425 return false;
70 38401026 }
71
72 bool NEWOUTOFBOUNDS(int32_t x, int32_t y, int32_t z)
73 {
74 return
75 (
76 (y > FFCore.enemy_removal_point[spriteremovalY2])
77 || (y < FFCore.enemy_removal_point[spriteremovalY1])
78 || (x < FFCore.enemy_removal_point[spriteremovalX1])
79 || (x > FFCore.enemy_removal_point[spriteremovalX2])
80 || (z < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (z > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 6655 static void position_relative_to_screen(zfix& x, zfix& y, int32_t rx, int32_t ry)
86 {
87 6655 x = rx + (x.getInt()/256)*256;
88 6655 y = ry + (y.getInt()/176)*176;
89 6655 }
90
91 namespace
92 {
93 int32_t trapConstantHorizontalID;
94 int32_t trapConstantVerticalID;
95 int32_t trapLOSHorizontalID;
96 int32_t trapLOSVerticalID;
97 int32_t trapLOS4WayID;
98
99 int32_t cornerTrapID;
100 int32_t centerTrapID;
101
102 int32_t rockID;
103 int32_t zoraID;
104 int32_t statueID;
105 }
106
107 423 void identifyCFEnemies()
108 {
109 423 trapConstantHorizontalID=-1;
110 423 trapConstantVerticalID=-1;
111 423 trapLOSHorizontalID=-1;
112 423 trapLOSVerticalID=-1;
113 423 trapLOS4WayID=-1;
114 423 cornerTrapID=-1;
115 423 centerTrapID=-1;
116 423 rockID=-1;
117 423 zoraID=-1;
118 423 statueID=-1;
119
120
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 423 times.
216999 for(int32_t i=0; i<eMAXGUYS; i++)
121 {
122
3/4
✓ Branch 0 taken 417 times.
✓ Branch 1 taken 216159 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 417 times.
216576 if((guysbuf[i].flags&guy_trph) && trapLOSHorizontalID==-1)
123 417 trapLOSHorizontalID=i;
124
4/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 216144 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_trpv) && trapLOSVerticalID==-1)
125 423 trapLOSVerticalID=i;
126
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 216153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_trp4) && trapLOS4WayID==-1)
127 423 trapLOS4WayID=i;
128
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 216153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_trplr) && trapConstantHorizontalID==-1)
129 423 trapConstantHorizontalID=i;
130
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 216153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_trpud) && trapConstantVerticalID==-1)
131 423 trapConstantVerticalID=i;
132
133
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 216153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_trap) && cornerTrapID==-1)
134 423 cornerTrapID=i;
135
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 216153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_trp2) && centerTrapID==-1)
136 423 centerTrapID=i;
137
138
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 216153 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags&guy_rock) && rockID==-1)
139 423 rockID=i;
140
4/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 216130 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 420 times.
216576 if((guysbuf[i].flags&guy_zora) && zoraID==-1)
141 420 zoraID=i;
142
143
4/4
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 216090 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 423 times.
216576 if((guysbuf[i].flags & guy_fire) && statueID==-1)
144 423 statueID=i;
145 216576 }
146 423 }
147
148 32 int32_t random_layer_enemy(int screen)
149 {
150 32 int32_t cnt=count_layer_enemies(screen);
151 32 mapscr* base_scr = get_scr(screen);
152
153
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(cnt==0)
154 {
155 return eNONE;
156 }
157
158 32 int32_t ret=zc_oldrand()%cnt;
159 32 cnt=0;
160
161
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 for(int32_t i=0; i<6; ++i)
162 {
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(base_scr->layermap[i]!=0)
164 {
165 32 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
166
167
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 for(int32_t j=0; j<10; ++j)
168 {
169
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
170 {
171
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 108 times.
140 if(cnt==ret)
172 {
173 32 return layerscreen->enemy[j];
174 }
175
176 108 ++cnt;
177 108 }
178 108 }
179 }
180 }
181
182 return eNONE;
183 32 }
184
185 49 int32_t count_layer_enemies(int screen)
186 {
187 49 int32_t cnt=0;
188
189 49 mapscr* base_scr = get_scr(screen);
190
191
2/2
✓ Branch 0 taken 294 times.
✓ Branch 1 taken 49 times.
343 for(int32_t i=0; i<6; ++i)
192 {
193
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 79 times.
294 if (base_scr->layermap[i])
194 {
195 79 const mapscr* layerscreen = get_canonical_scr(base_scr->layermap[i]-1, base_scr->layerscreen[i]);
196
197
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 79 times.
869 for(int32_t j=0; j<10; ++j)
198 {
199
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 420 times.
790 if(layerscreen->enemy[j]!=0)
200 {
201 420 ++cnt;
202 420 }
203 790 }
204 79 }
205 294 }
206
207 49 return cnt;
208 }
209
210 201020 int32_t hero_on_wall()
211 {
212 201020 zfix lx = Hero.getX();
213 201020 zfix ly = Hero.getY();
214
215
4/4
✓ Branch 0 taken 185095 times.
✓ Branch 1 taken 15925 times.
✓ Branch 2 taken 8814 times.
✓ Branch 3 taken 176281 times.
201020 if(lx>=48 && lx<=world_w-64)
216 {
217
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 176050 times.
176281 if(ly==32) return up+1;
218
219
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 175770 times.
176050 if(ly==world_h-48) return down+1;
220 175770 }
221
222
4/4
✓ Branch 0 taken 183267 times.
✓ Branch 1 taken 17242 times.
✓ Branch 2 taken 21012 times.
✓ Branch 3 taken 162255 times.
200509 if(ly>=48 && ly<=world_h-64)
223 {
224
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 162039 times.
162255 if(lx==32) return left+1;
225
226
2/2
✓ Branch 0 taken 161935 times.
✓ Branch 1 taken 104 times.
162039 if(lx==world_w-48) return right+1;
227 161935 }
228
229 200189 return 0;
230 201020 }
231
232 806828 bool tooclose(int32_t x,int32_t y,int32_t d)
233 {
234
2/2
✓ Branch 0 taken 600820 times.
✓ Branch 1 taken 206008 times.
806828 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
235 }
236
237 4019514 bool enemy::overpit(enemy *e)
238 {
239 // This function (and shadow_overpit) has been broken since it was written, and only
240 // checked the same diagonal of the hitbox, over and over again. The bug is because both
241 // loops used the same variable name.
242 // Checking literally every pixel seems like overkill, so for now let's continue to
243 // do the single diagonal but just once. That's why the outer loop is commented out.
244
245 // for ( int32_t q = 0; q < hxsz; ++q )
246 {
247
2/2
✓ Branch 0 taken 37189774 times.
✓ Branch 1 taken 4000312 times.
41190086 for ( int32_t q = 0; q < hit_height; ++q )
248 {
249 //check every pixel of the hitbox
250
2/2
✓ Branch 0 taken 19202 times.
✓ Branch 1 taken 37170572 times.
37189774 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
251 {
252 //if the hitbox is over a pit, we can't land
253 19202 return true;
254 }
255 37170572 }
256 }
257 4000312 return false;
258 4019514 }
259
260 12362880 bool enemy::shadow_overpit(enemy *e)
261 {
262 // for ( int32_t q = 0; q < hxsz; ++q )
263 {
264
2/2
✓ Branch 0 taken 177593778 times.
✓ Branch 1 taken 12336419 times.
189930197 for ( int32_t q = 0; q < hit_height; ++q )
265 {
266 //check every pixel of the hitbox
267
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 177567317 times.
177593778 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
268 {
269 //if the hitbox is over a pit, we can't land
270 26461 return true;
271 }
272 177567317 }
273 }
274 12336419 return false;
275 12362880 }
276
277 // Returns true iff a combo type or flag precludes enemy movement.
278 7425845 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
279 {
280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7425845 times.
7425845 if(moveflags & move_ignore_blockflags) return false;
281 7425845 int32_t c = COMBOTYPE(dx,dy);
282
4/4
✓ Branch 0 taken 4886971 times.
✓ Branch 1 taken 2538874 times.
✓ Branch 2 taken 1396113 times.
✓ Branch 3 taken 1142761 times.
9964719 bool pit_blocks = (!(moveflags & (move_can_pitwalk|move_only_pitwalk)) && (!(moveflags & move_can_pitfall) || !isKB));
283
3/6
✓ Branch 0 taken 2520550 times.
✓ Branch 1 taken 4905295 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2520550 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7425845 bool water_blocks = (!(moveflags & (move_can_waterwalk|move_only_waterwalk|move_only_shallow_waterwalk)) && (!(moveflags & move_can_waterdrown) || !isKB) && get_qr(qr_DROWN));
284
5/6
✓ Branch 0 taken 2580096 times.
✓ Branch 1 taken 4845749 times.
✓ Branch 2 taken 2578219 times.
✓ Branch 3 taken 1877 times.
✓ Branch 4 taken 2578219 times.
✗ Branch 5 not taken.
14852454 return c==cPIT || c==cPITB || c==cPITC ||
285
4/6
✓ Branch 0 taken 2578219 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2578219 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2429471 times.
✓ Branch 5 taken 148748 times.
2578219 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
286 // Block enemies type and block enemies flags
287
2/2
✓ Branch 0 taken 2572943 times.
✓ Branch 1 taken 2424195 times.
148748 combo_class_buf[c].block_enemies&1 ||
288
4/4
✓ Branch 0 taken 2570273 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 2570026 times.
✓ Branch 3 taken 247 times.
2572943 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
289
4/4
✓ Branch 0 taken 2569208 times.
✓ Branch 1 taken 818 times.
✓ Branch 2 taken 2569142 times.
✓ Branch 3 taken 66 times.
2570026 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
290 // Check for ladder-only combos which aren't dried water
291
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 2558516 times.
✓ Branch 2 taken 10331 times.
✓ Branch 3 taken 295 times.
5137989 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
292 // Check for drownable water
293
4/4
✓ Branch 0 taken 574658 times.
✓ Branch 1 taken 1994189 times.
✓ Branch 2 taken 2332 times.
✓ Branch 3 taken 572326 times.
2568847 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true, false, false)));
294 2582737 }
295
296 // Returns true iff enemy is floating and blocked by a combo type or flag.
297 8686740 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
298 {
299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8686740 times.
8686740 if(moveflags & move_ignore_blockflags) return false;
300
4/4
✓ Branch 0 taken 6589882 times.
✓ Branch 1 taken 2096858 times.
✓ Branch 2 taken 1748080 times.
✓ Branch 3 taken 348778 times.
10783598 bool pit_blocks = (!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !isKB));
301
3/4
✓ Branch 0 taken 6604389 times.
✓ Branch 1 taken 2082351 times.
✓ Branch 2 taken 2082351 times.
✗ Branch 3 not taken.
10769091 bool water_blocks = (!(moveflags & move_can_waterwalk) && (!(moveflags & move_can_waterdrown) || !isKB));
302
2/2
✓ Branch 0 taken 1199887 times.
✓ Branch 1 taken 7486853 times.
16173593 return ((special==spw_floater)&&
303
2/2
✓ Branch 0 taken 7476710 times.
✓ Branch 1 taken 10143 times.
7486853 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
304
2/2
✓ Branch 0 taken 7476591 times.
✓ Branch 1 taken 119 times.
7476710 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
305
2/2
✓ Branch 0 taken 7476420 times.
✓ Branch 1 taken 171 times.
7476591 (MAPFLAG(dx,dy)==mfNOENEMY)||
306
2/2
✓ Branch 0 taken 7476165 times.
✓ Branch 1 taken 255 times.
7476420 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
307
4/4
✓ Branch 0 taken 1242529 times.
✓ Branch 1 taken 6233636 times.
✓ Branch 2 taken 4004 times.
✓ Branch 3 taken 1238525 times.
14948326 (water_blocks && iswaterex_z3(MAPCOMBO(dx, dy), -1, dx,dy, false, false, true)) ||
308
2/2
✓ Branch 0 taken 6224047 times.
✓ Branch 1 taken 1248114 times.
7472161 (pit_blocks && ispitfall(dx,dy))));
309 8686740 }
310 // Returns true iff a combo type or flag precludes enemy movement.
311 281968 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
312 {
313 281968 int32_t c = COMBOTYPE(dx,dy);
314 281968 bool pit_blocks = !(gd.moveflags & move_can_pitwalk);
315
2/2
✓ Branch 0 taken 35536 times.
✓ Branch 1 taken 246432 times.
281968 bool water_blocks = !(gd.moveflags & move_can_waterwalk) && get_qr(qr_DROWN);
316
5/6
✓ Branch 0 taken 281948 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 281831 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 281831 times.
✗ Branch 5 not taken.
1062605 return c==cPIT || c==cPITB || c==cPITC ||
317
4/6
✓ Branch 0 taken 281831 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 281831 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249976 times.
✓ Branch 5 taken 31855 times.
281831 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
318 // Block enemies type and block enemies flags
319
2/2
✓ Branch 0 taken 281258 times.
✓ Branch 1 taken 249403 times.
31855 combo_class_buf[c].block_enemies&1 ||
320
4/4
✓ Branch 0 taken 280871 times.
✓ Branch 1 taken 387 times.
✓ Branch 2 taken 280840 times.
✓ Branch 3 taken 31 times.
281258 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
321
4/4
✓ Branch 0 taken 277185 times.
✓ Branch 1 taken 3655 times.
✓ Branch 2 taken 276910 times.
✓ Branch 3 taken 275 times.
280840 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
322 // Check for ladder-only combos which aren't dried water
323
4/4
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 275866 times.
✓ Branch 2 taken 1005 times.
✓ Branch 3 taken 39 times.
553781 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
324 // Check for drownable water
325
4/4
✓ Branch 0 taken 53168 times.
✓ Branch 1 taken 223703 times.
✓ Branch 2 taken 28535 times.
✓ Branch 3 taken 24633 times.
276871 (water_blocks && !(isSideViewGravity()) && (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)));
326 }
327
328 // Returns true iff enemy is floating and blocked by a combo type or flag.
329 139610 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
330 {
331
2/2
✓ Branch 0 taken 137287 times.
✓ Branch 1 taken 2323 times.
139610 bool pit_blocks = (!(gd.moveflags & move_can_pitwalk) && !(gd.moveflags & move_can_pitfall));
332 139610 bool water_blocks = !(gd.moveflags & move_can_waterwalk);
333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139610 times.
279220 return ((special==spw_floater)&&
334
2/2
✓ Branch 0 taken 139513 times.
✓ Branch 1 taken 97 times.
139610 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
335
2/2
✓ Branch 0 taken 139508 times.
✓ Branch 1 taken 5 times.
139513 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
336
2/2
✓ Branch 0 taken 139499 times.
✓ Branch 1 taken 9 times.
139508 (MAPFLAG(dx,dy)==mfNOENEMY)||
337
2/2
✓ Branch 0 taken 139470 times.
✓ Branch 1 taken 29 times.
139499 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
338
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 137149 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
278690 (water_blocks && iswaterex_z3(MAPCOMBO(dx,dy), -1, dx, dy, false, false, true)) ||
339
2/2
✓ Branch 0 taken 137149 times.
✓ Branch 1 taken 2071 times.
139220 (pit_blocks && ispitfall(dx,dy))));
340 }
341
342
5/10
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115111 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115111 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115111 times.
✗ Branch 9 not taken.
230222 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
343 115111 {
344
1/2
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
115111 x=X;
345
1/2
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
115111 y=Y;
346
3/6
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115111 times.
✗ Branch 5 not taken.
115111 screen_spawned=get_screen_for_world_xy(x.getInt(), y.getInt());
347 115111 id=Id;
348 115111 clk=Clk;
349
1/2
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
115111 floor_y=y;
350 115111 ceiling=false;
351 115111 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
352 115111 grumble = movestatus = posframe = timer = ox = oy = 0;
353
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115111 times.
✓ Branch 2 taken 115111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115111 times.
✗ Branch 5 not taken.
115111 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
354 115111 did_armos=true;
355 115111 script_spawned=false;
356
357 115111 d = guysbuf + (id & 0xFFF);
358 115111 hp = d->hp;
359 115111 starting_hp = hp;
360 // cs = d->cset;
361 //d variables
362
363 115111 flags=d->flags;
364 115111 flags=d->flags;
365 115111 s_tile=d->s_tile; //secondary (additional) tile(s)
366 115111 family=d->family;
367 115111 dcset=d->cset;
368 115111 cs=dcset;
369
2/2
✓ Branch 0 taken 89098 times.
✓ Branch 1 taken 26013 times.
115111 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
370 115111 dp=d->dp;
371 115111 wdp=d->wdp;
372 115111 wpn=d->weapon;
373 115111 wpnsprite = d-> wpnsprite; //2.6 -Z
374 115111 rate=d->rate;
375 115111 hrate=d->hrate;
376
1/2
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
115111 dstep=d->step;
377 115111 homing=d->homing;
378 115111 dmisc1=d->attributes[0];
379 115111 dmisc2=d->attributes[1];
380 115111 dmisc3=d->attributes[2];
381 115111 dmisc4=d->attributes[3];
382 115111 dmisc5=d->attributes[4];
383 115111 dmisc6=d->attributes[5];
384 115111 dmisc7=d->attributes[6];
385 115111 dmisc8=d->attributes[7];
386 115111 dmisc9=d->attributes[8];
387 115111 dmisc10=d->attributes[9];
388 115111 dmisc11=d->attributes[10];
389 115111 dmisc12=d->attributes[11];
390 115111 dmisc13=d->attributes[12];
391 115111 dmisc14=d->attributes[13];
392 115111 dmisc15=d->attributes[14];
393 115111 dmisc16=d->attributes[15];
394 115111 dmisc17=d->attributes[16];
395 115111 dmisc18=d->attributes[17];
396 115111 dmisc19=d->attributes[18];
397 115111 dmisc20=d->attributes[19];
398 115111 dmisc21=d->attributes[20];
399 115111 dmisc22=d->attributes[21];
400 115111 dmisc23=d->attributes[22];
401 115111 dmisc24=d->attributes[23];
402 115111 dmisc25=d->attributes[24];
403 115111 dmisc26=d->attributes[25];
404 115111 dmisc27=d->attributes[26];
405 115111 dmisc28=d->attributes[27];
406 115111 dmisc29=d->attributes[28];
407 115111 dmisc30=d->attributes[29];
408 115111 dmisc31=d->attributes[30];
409 115111 dmisc32=d->attributes[31];
410
2/2
✓ Branch 0 taken 4277 times.
✓ Branch 1 taken 110834 times.
115111 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
411 {
412 110834 dmisc31 = dmisc32;
413 110834 dmisc32 = 0;
414 110834 }
415 115111 spr_shadow=d->spr_shadow;
416 115111 spr_death=d->spr_death;
417 115111 spr_spawn=d->spr_spawn;
418
419
2/2
✓ Branch 0 taken 4719551 times.
✓ Branch 1 taken 115111 times.
4834662 for(int32_t i=0; i<edefLAST255; i++)
420 4719551 defense[i]=d->defense[i];
421
422 115111 bgsfx=d->bgsfx;
423 115111 hitsfx=d->hitsfx;
424 115111 deadsfx=d->deadsfx;
425 115111 bosspal=d->bosspal;
426
427 115111 frozentile = d->frozentile;
428
429 115111 frozencset = d->frozencset;
430 115111 frozenclock = 0;
431
2/2
✓ Branch 0 taken 1151110 times.
✓ Branch 1 taken 115111 times.
1266221 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
432
433
2/2
✓ Branch 0 taken 1956887 times.
✓ Branch 1 taken 115111 times.
2071998 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
434 //firesfx = 0; //t.b.a -Z
435 115111 isCore = true; //t.b.a
436 115111 parentCore = 0; //t.b.a
437
438 115111 firesfx = d->firesfx;
439
2/2
✓ Branch 0 taken 3683552 times.
✓ Branch 1 taken 115111 times.
3798663 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
440
2/2
✓ Branch 0 taken 3683552 times.
✓ Branch 1 taken 115111 times.
3798663 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
441
442 115111 script = d->script;
443
444
2/2
✓ Branch 0 taken 920888 times.
✓ Branch 1 taken 115111 times.
1035999 for ( int32_t q = 0; q < 8; q++ )
445 {
446 920888 initD[q] = d->initD[q];
447 920888 }
448
449 115111 stickclk = 0;
450 115111 submerged = false;
451 115111 didScriptThisFrame = false;
452 115111 ffcactivated = std::nullopt;
453 115111 hitdir = -1;
454 115111 editorflags = d->editorflags; //set by Enemy Editor
455 //Set the drawing flag for this sprite.
456
1/2
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
115111 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
457
458
459
2/2
✓ Branch 0 taken 8918 times.
✓ Branch 1 taken 106193 times.
115111 if(bosspal>-1)
460 {
461
1/2
✓ Branch 0 taken 8918 times.
✗ Branch 1 not taken.
8918 loadpalset(csBOSS,pSprite(bosspal));
462 8918 }
463
464
2/2
✓ Branch 0 taken 50322 times.
✓ Branch 1 taken 64789 times.
115111 if(bgsfx>-1)
465 {
466
1/2
✓ Branch 0 taken 50322 times.
✗ Branch 1 not taken.
50322 cont_sfx(bgsfx);
467 50322 }
468
469
2/2
✓ Branch 0 taken 89098 times.
✓ Branch 1 taken 26013 times.
115111 if(get_qr(qr_NEWENEMYTILES))
470 {
471 89098 o_tile=d->e_tile;
472 89098 frate = d->e_frate;
473 89098 }
474 else
475 {
476 26013 o_tile=d->tile;
477 26013 frate = d->frate;
478 }
479
480 115111 tile=0; //init to 0 here, but set it later.
481
482 115111 scripttile = -1;
483 115111 scriptflip = -1;
484 115111 do_animation = true;
485 115111 immortal = false;
486 115111 noSlide = false;
487 115111 deathexstate = -1;
488
489 115111 hashero=false;
490
491 // If they forgot the invisibility flag, here's another failsafe:
492
4/4
✓ Branch 0 taken 5792 times.
✓ Branch 1 taken 109319 times.
✓ Branch 2 taken 5698 times.
✓ Branch 3 taken 94 times.
115111 if(o_tile==0 && family!=eeSPINTILE)
493
1/2
✓ Branch 0 taken 5698 times.
✗ Branch 1 not taken.
5698 flags |= guy_invisible;
494
495 // step = d->step/100.0;
496 // To preserve the odd step values for Keese & Gleeok heads. -L
497
5/8
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12297 times.
✓ Branch 5 taken 102814 times.
✓ Branch 6 taken 12297 times.
✗ Branch 7 not taken.
115111 if(dstep==62.0) dstep+=0.5;
498
5/8
✓ Branch 0 taken 102814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 699 times.
✓ Branch 5 taken 102115 times.
✓ Branch 6 taken 699 times.
✗ Branch 7 not taken.
102814 else if(dstep==89) dstep-=1/9;
499
500
5/10
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 115111 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 115111 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115111 times.
✗ Branch 9 not taken.
115111 step = zslongToFix(dstep*100);
501
502
503 115111 item_set = d->item_set;
504 115111 grumble = d->grumble;
505
506
2/2
✓ Branch 0 taken 90225 times.
✓ Branch 1 taken 24886 times.
115111 if(frate == 0)
507 24886 frate = 256;
508
509 115111 leader = itemguy = dying = scored = false;
510 115111 canfreeze = count_enemy = true;
511
1/2
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
115111 mainguy = !(flags & guy_doesnt_count);
512
1/2
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
115111 dir = zc_oldrand()&3;
513
514 //2.6 Enemy Editor Hit and TIle Sizes
515
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115111 if ( ((d->SIZEflags&OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
516 // al_trace("Enemy txsz:%i\n", txsz);
517
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 115102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
115111 if ( ((d->SIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
518
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115111 if ( ((d->SIZEflags&OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
519
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 115104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
115111 if ( ((d->SIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115111 if ( ((d->SIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
521
1/2
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
115111 if ( (d->SIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
522
1/2
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
115111 if ( (d->SIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
523 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115111 if ( (d->SIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115111 times.
115111 if ( (d->SIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
526 {
527 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
528 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
529 }
530
531
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 115111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
115111 if ( (d->SIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
532
533 115111 SIZEflags = d->SIZEflags;
534
535
8/10
✓ Branch 0 taken 114862 times.
✓ Branch 1 taken 249 times.
✓ Branch 2 taken 366 times.
✓ Branch 3 taken 114745 times.
✓ Branch 4 taken 366 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 366 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 365 times.
115111 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
536 1 wpn = 0;
537
538 //tile should never be 0 after init --Z (failsafe)
539
4/6
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 107867 times.
✓ Branch 5 taken 7244 times.
115111 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
540
541 //Moveflags; for gravity and pit interaction
542 115111 moveflags = d->moveflags;
543
3/4
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17669 times.
✓ Branch 3 taken 97442 times.
115111 if(!can_pitfall(false))
544 {
545 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
546
2/4
✓ Branch 0 taken 17669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17669 times.
✗ Branch 3 not taken.
17669 moveflags &= ~move_can_pitfall;
547
2/4
✓ Branch 0 taken 17669 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17669 times.
✗ Branch 3 not taken.
17669 moveflags &= ~move_can_waterdrown;
548 17669 }
549
550 115111 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
551
552 115111 specialsfx = d->specialsfx;
553
1/2
✓ Branch 0 taken 115111 times.
✗ Branch 1 not taken.
115111 weap_data = d->weap_data;
554 115111 }
555
556 114854 enemy::~enemy()
557 114854 {
558
2/4
✓ Branch 0 taken 114854 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114854 times.
✗ Branch 3 not taken.
114854 FFCore.destroyScriptableObject(ScriptType::NPC, getUID());
559
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 114842 times.
114854 if(hashero)
560 {
561
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 Hero.setEaten(0);
562 12 hashero=false;
563 12 }
564 114854 }
565
566 bool enemy::is_move_paused()
567 {
568 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
569 }
570
571 7024 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
572 {
573 7024 int32_t yg = (special==spw_floater)?8:0;
574 7024 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
575
576
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_x == -1000)
577 input_x = dx;
578
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 if(input_y == -1000)
579 input_y = dy;
580
581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
14048 if(!(moveflags & move_ignore_screenedge)
582
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7024 times.
✓ Branch 4 taken 6707 times.
✓ Branch 5 taken 317 times.
7024 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
583
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 || ((input_x+hit_width-1) >= (world_w-16+nb)) || ((input_y+hit_height-1) >= (world_h-16+nb))))
584 return true;
585
586
4/6
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6934 times.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
7024 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
587 {
588 if(ispitfall(dx,dy))
589 return true;
590 }
591
592 7024 bool flying = false;
593 7024 bool cansolid = false;
594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 if(moveflags & move_ignore_solidity)
595 cansolid = true;
596
2/4
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7024 switch(special)
597 {
598 case spw_clipbottomright:
599 if(dy>=128 || dx>=208) return true;
600 break;
601 case spw_clipright:
602 break; //if(input_x>=208) return true; break;
603
604 case spw_wizzrobe: // fall through
605 case spw_floater: // Special case for fliers and wizzrobes - hack!
606 {
607
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
317 if(isdungeon(screen_spawned) && !(moveflags & move_ignore_screenedge))
608 {
609 if(dy < 32-yg || dy >= 144) return true;
610 if(dx < 32 || dx >= 224) return true;
611 }
612
2/4
✓ Branch 0 taken 317 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
✗ Branch 3 not taken.
317 if(!(moveflags & move_ignore_blockflags) && flyerblocked(dx, dy, special, kb))
613 return true;
614 317 cansolid = true;
615 317 flying = true;
616 }
617 317 }
618
619 7024 dx = TRUNCATE_HALF_TILE(dx);
620 7024 dy = TRUNCATE_HALF_TILE(dy);
621
622
4/6
✓ Branch 0 taken 6707 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 6707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6707 times.
✗ Branch 5 not taken.
7024 if(!flying && !(moveflags & move_ignore_blockflags) && groundblocked(dx,dy,kb)) return true;
623
624
4/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7024 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7024 times.
7024 if (dx < 0 || dx >= world_w || dy < 0 || dy >= world_h)
625 return !(moveflags & move_ignore_screenedge);
626
627 // TODO: could this reuse _walkflag?
628
629 //_walkflag code
630 7024 mapscr* s0 = get_scr_for_world_xy_layer(dx, dy, 0);
631
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 mapscr* s1 = s0->layermap[0]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 1) : nullptr;
632
2/2
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
7024 mapscr* s2 = s0->layermap[1]-1 >= 0 ? get_scr_for_world_xy_layer(dx, dy, 2) : nullptr;
633
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 if (!s1 || !s1->valid) s1 = s0;
634
4/4
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 5986 times.
✓ Branch 2 taken 383 times.
✓ Branch 3 taken 655 times.
7024 if (!s2 || !s2->valid) s2 = s0;
635
636 7024 int32_t cpos = COMBOPOS(dx%256, dy%176);
637
2/4
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7024 times.
✗ Branch 3 not taken.
7024 int32_t ci = s0->data[cpos], ci1 = (s1?s1:s0)->data[cpos], ci2 = (s2?s2:s0)->data[cpos];
638 7024 newcombo c = combobuf[ci];
639
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 newcombo c1 = combobuf[ci1];
640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7024 times.
7024 newcombo c2 = combobuf[ci2];
641
642 7024 int32_t b=1;
643
2/2
✓ Branch 0 taken 3446 times.
✓ Branch 1 taken 3578 times.
7024 if(dx&8) b<<=2;
644
2/2
✓ Branch 0 taken 3374 times.
✓ Branch 1 taken 3650 times.
7024 if(dy&8) b<<=1;
645
646 #define iwtr(cmb, x, y, shallow) \
647 (shallow \
648 ? iswaterex_z3(cmb, -1, dx, dy, false, false, false, true, false) \
649 && !iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false) \
650 : iswaterex_z3(cmb, -1, dx, dy, false, false, false, false, false))
651
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool wtr = iwtr(ci, dx, dy, false);
652
4/6
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3473 times.
✓ Branch 3 taken 3551 times.
✓ Branch 4 taken 3473 times.
✗ Branch 5 not taken.
7024 bool shwtr = iwtr(ci, dx, dy, true);
653
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool pit = ispitfall(dx,dy);
654
655
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 90 times.
✗ Branch 7 not taken.
7024 bool canwtr = (moveflags & move_can_waterwalk) || ((moveflags & move_can_waterdrown) && kb);
656
5/8
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 6934 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 90 times.
7024 bool canpit = (moveflags & move_can_pitwalk) || ((moveflags & move_can_pitfall) && kb);
657
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needwtr = (moveflags & move_only_waterwalk);
658
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needshwtr = (moveflags & move_only_shallow_waterwalk);
659
1/2
✓ Branch 0 taken 7024 times.
✗ Branch 1 not taken.
7024 bool needpit = (moveflags & move_only_pitwalk);
660
661
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 6707 times.
7024 if(!cansolid)
662 {
663 6707 int32_t cwalkflag = c.walk & 0xF;
664
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6707 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s1)
666 {
667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c1.type == cBRIDGE)
668 {
669 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
670 {
671 int efflag = (c1.walk & 0xF0)>>4;
672 int newsolid = (c1.walk & 0xF);
673 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
674 }
675 else cwalkflag &= c1.walk;
676 }
677 6707 else cwalkflag |= c1.walk & 0xF;
678 6707 }
679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (s2)
680 {
681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6707 times.
6707 if (c2.type == cBRIDGE)
682 {
683 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
684 {
685 int efflag = (c2.walk & 0xF0)>>4;
686 int newsolid = (c2.walk & 0xF);
687 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
688 }
689 else cwalkflag &= c2.walk;
690 }
691 6707 else cwalkflag |= c2.walk & 0xF;
692 6707 }
693
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 6468 times.
6707 if(cwalkflag & b)
694 239 return true;
695 6468 }
696
3/6
✓ Branch 0 taken 6785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6785 times.
6785 if(needwtr || needshwtr || needpit)
697 {
698 bool ret = true;
699 if (needwtr && wtr) ret = false;
700 else if (needshwtr && shwtr) ret = false;
701 else if (needpit && pit) ret = false;
702 return ret;
703 }
704
3/4
✓ Branch 0 taken 3473 times.
✓ Branch 1 taken 3312 times.
✓ Branch 2 taken 3473 times.
✗ Branch 3 not taken.
6785 else if(wtr && !canwtr)
705 return true;
706
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6785 else if(pit && !canpit)
707 return true;
708
709 6785 return false;
710 7024 }
711
712 1535 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
713 {
714
3/4
✓ Branch 0 taken 424 times.
✓ Branch 1 taken 1111 times.
✓ Branch 2 taken 424 times.
✗ Branch 3 not taken.
1535 if(!(dx || dy)) return true;
715 1535 zfix bx = x+hxofs, by = y+hyofs; //left/top
716 1535 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
717
3/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 1019 times.
✗ Branch 3 not taken.
1535 if(!ign_sv && dy < 0) //check gravity
718 {
719 if((moveflags & move_obeys_grav) && isSideViewGravity())
720 return false;
721 }
722
723
2/4
✓ Branch 0 taken 1535 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1535 times.
1535 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
724
725
3/4
✓ Branch 0 taken 1111 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1111 times.
1535 if(dx && !dy)
726 {
727
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 341 times.
1111 if(dx < 0)
728 {
729
2/4
✓ Branch 0 taken 770 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 770 times.
770 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
730 770 int mx = (bx+dx).getFloor();
731
2/2
✓ Branch 0 taken 2976 times.
✓ Branch 1 taken 770 times.
3746 for(zfix ty = 0; by+ty < ry; ty += 8)
732 {
733
1/2
✓ Branch 0 taken 2976 times.
✗ Branch 1 not taken.
2976 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
734 return false;
735 2976 }
736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 770 times.
770 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
737 return false;
738
3/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 736 times.
✗ Branch 3 not taken.
770 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
739 return false;
740 770 }
741 else
742 {
743 341 int mx = (rx+dx).getCeil();
744 341 int lx = mx-hit_width+1;
745
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 340 times.
2482 for(zfix ty = 0; by+ty < ry; ty += 8)
746 {
747
2/2
✓ Branch 0 taken 2141 times.
✓ Branch 1 taken 1 times.
2142 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
748 1 return false;
749 2141 }
750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
751 return false;
752
2/4
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 340 times.
✗ Branch 3 not taken.
340 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
753 return false;
754 }
755 1110 }
756
2/4
✓ Branch 0 taken 424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 424 times.
424 else if(dy && !dx)
757 {
758
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 109 times.
424 if(dy < 0)
759 {
760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 315 times.
315 special = (special==spw_clipbottomright)?spw_none:special;
761 315 int my = (by+dy).getFloor();
762
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 77 times.
469 for(zfix tx = 0; bx+tx < rx; tx += 8)
763 {
764
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 238 times.
392 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
765 238 return false;
766 154 }
767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(scr_walkflag(rx, my, special, up, bx, my, kb))
768 return false;
769
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
77 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
770 return false;
771 77 }
772 else
773 {
774 109 int my = (ry+dy).getCeil();
775 109 int ly = my-hit_height+1;
776
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109 times.
327 for(zfix tx = 0; bx+tx < rx; tx += 8)
777 {
778
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
779 return false;
780 218 }
781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
782 return false;
783
3/4
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 89 times.
109 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
784 return false;
785 }
786 186 }
787 else //! Untested, and currently unused.
788 {
789 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
790 }
791 1296 return true;
792 1535 }
793
794 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
795 {
796 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
797 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
798
799 bool nosolid = !((moveflags & move_ignore_solidity) || (special==spw_wizzrobe) || (special==spw_floater));
800
801 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
802 return false;
803 for(zfix ty = 0; by+ty < ry; ty += 8)
804 {
805 for(zfix tx = 0; bx+tx < rx; tx += 8)
806 {
807 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
808 return false;
809 }
810 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
811 return false;
812 }
813 for(zfix tx = 0; bx+tx < rx; tx += 8)
814 {
815 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
816 return false;
817 }
818 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
819 return false;
820 return true;
821 }
822
823 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
824 {
825 auto oxsz = hit_width, oysz = hit_height;
826 if(nwid > -1) hit_width = nwid;
827 if(nhei > -1) hit_height = nhei;
828 bool ret = scr_canplace(dx,dy,special,kb);
829 hit_width = oxsz; hit_height = oysz;
830 return ret;
831 }
832
833 1311 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
834 {
835 1311 bool ret = true;
836
3/8
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1311 if(!ign_sv && dy < 0 && (moveflags & move_obeys_grav) && isSideViewGravity())
837 dy = 0;
838 1311 const int scl = 2;
839
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 1345 times.
✓ Branch 2 taken 294 times.
✓ Branch 3 taken 1311 times.
1605 while(abs(dx) > scl || abs(dy) > scl)
840 {
841
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 34 times.
294 if(abs(dx) > abs(dy))
842 {
843 260 int32_t tdx = dx.sign() * scl;
844
1/2
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
260 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
845 260 dx -= tdx;
846 else
847 {
848 if(earlyret) return false;
849 dx = tdx;
850 ret = false;
851 }
852 260 }
853 else
854 {
855 34 int32_t tdy = dy.sign() * scl;
856
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
34 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
857 27 dy -= tdy;
858 else
859 {
860
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(earlyret) return false;
861 7 dy = tdy;
862 7 ret = false;
863 }
864 }
865 }
866
867
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 1111 times.
1311 if(dx)
868 {
869
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 1 times.
1111 if(scr_canmove(dx, 0, special, kb, ign_sv))
870 1110 x += dx;
871 else
872 {
873
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
874 ret = false;
875 int xsign = dx.sign();
876 while(scr_canmove(xsign, 0, special, kb, ign_sv))
877 {
878 x += xsign;
879 dx -= xsign;
880 }
881 if(dx)
882 {
883 dx.doDecBound(0,-9999, 0,9999);
884 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
885 if(scr_canmove(val, 0, special, kb, ign_sv))
886 {
887 retval = val;
888 return BSEARCH_CONTINUE_AWAY0;
889 }
890 else return BSEARCH_CONTINUE_TOWARD0;
891 });
892 x += dx;
893 }
894 }
895 1110 }
896
2/2
✓ Branch 0 taken 1110 times.
✓ Branch 1 taken 200 times.
1310 if(dy)
897 {
898
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 14 times.
200 if(scr_canmove(0, dy, special, kb, ign_sv))
899 186 y += dy;
900 else
901 {
902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(earlyret) return false;
903 14 ret = false;
904 14 int ysign = dy.sign();
905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 while(scr_canmove(0, ysign, special, kb, ign_sv))
906 {
907 y += ysign;
908 dy -= ysign;
909 }
910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(dy)
911 {
912 14 dy.doDecBound(0,-9999, 0,9999);
913
3/6
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
224 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(scr_canmove(0, val, special, kb, ign_sv))
915 {
916 retval = val;
917 return BSEARCH_CONTINUE_AWAY0;
918 }
919 210 else return BSEARCH_CONTINUE_TOWARD0;
920 210 });
921 14 y += dy;
922 14 }
923 }
924 200 }
925 1310 return ret;
926 1311 }
927
928 754 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
929 {
930
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 752 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
754 static const zfix diagrate = zslongToFix(7071);
931
5/13
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 479 times.
✓ Branch 7 taken 259 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
754 switch(NORMAL_DIR(dir))
932 {
933 case up:
934 return movexy(0, -px, special, kb, false, earlyret);
935 case down:
936 16 return movexy(0, px, special, kb, false, earlyret);
937 case left:
938 479 return movexy(-px, 0, special, kb, false, earlyret);
939 case right:
940 259 return movexy(px, 0, special, kb, false, earlyret);
941 case r_up:
942 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
943 case r_down:
944 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
945 case l_up:
946 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
947 case l_down:
948 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
949 }
950 return false;
951 754 }
952
953 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
954 {
955 double v = degrees.getFloat() * PI / 180.0;
956 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
957 return movexy(dx, dy, special, kb, false, earlyret);
958 }
959
960 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
961 {
962 zfix tx = x, ty = y;
963 bool ret = movexy(dx, dy, special, kb, false, true);
964 x = tx;
965 y = ty;
966 return ret;
967 }
968 754 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
969 {
970 754 zfix tx = x, ty = y;
971 754 bool ret = moveDir(dir, px, special, kb, true);
972 754 x = tx;
973 754 y = ty;
974 754 return ret;
975 }
976 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
977 {
978 zfix tx = x, ty = y;
979 bool ret = moveAtAngle(degrees, px, special, kb, true);
980 x = tx;
981 y = ty;
982 return ret;
983 }
984
985 // Handle pitfalls
986 37850529 bool enemy::do_falling(int32_t index)
987 {
988
2/2
✓ Branch 0 taken 37848162 times.
✓ Branch 1 taken 2367 times.
37850529 if(fallclk > 0)
989 {
990
4/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2333 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 20 times.
2367 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
991
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 22 times.
2367 if(!--fallclk)
992 {
993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(immortal) //Keep alive forever
994 ++fallclk; //force another frame of falling.... forever.
995
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 else if(dying) //Give 1 frame for script revival
996 {
997
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(flags&guy_never_return)
998 never_return(screen_spawned, index);
999
1000
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(leader)
1001 kill_em_all();
1002
1003 //leave_item(); //Don't drop items in pits!
1004 11 stop_bgsfx(index);
1005 11 return true;
1006 }
1007 else
1008 {
1009 11 try_death(true); //Force death
1010 11 ++fallclk; //force another frame of falling
1011 }
1012 11 }
1013
1014 2356 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1015 2356 cs = spr.csets & 0xF;
1016
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t fr = spr.frames ? spr.frames : 1;
1017
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 int32_t spd = spr.speed ? spr.speed : 1;
1018 2356 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1019
2/2
✓ Branch 0 taken 1148 times.
✓ Branch 1 taken 1208 times.
2356 tile = spr.tile + zc_min(animclk / spd, fr-1);
1020 2356 }
1021 37850518 return false;
1022 37850529 }
1023
1024 // Handle drowning in water
1025 37848162 bool enemy::do_drowning(int32_t index)
1026 {
1027
1/2
✓ Branch 0 taken 37848162 times.
✗ Branch 1 not taken.
37848162 if(drownclk > 0)
1028 {
1029 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1030 //!TODO: Drown SFX
1031 if(!--drownclk)
1032 {
1033 if(immortal) //Keep alive forever
1034 ++drownclk; //force another frame of falling.... forever.
1035 else if(dying) //Give 1 frame for script revival
1036 {
1037 if(flags&guy_never_return)
1038 never_return(screen_spawned, index);
1039
1040 if(leader)
1041 kill_em_all();
1042
1043 //leave_item(); //Don't drop items in pits!
1044 stop_bgsfx(index);
1045 return true;
1046 }
1047 else
1048 {
1049 try_death(true); //Force death
1050 ++drownclk; //force another frame of falling
1051 }
1052 }
1053
1054 bool lava = (drownCombo && combobuf[drownCombo].usrflags&cflag1);
1055 wpndata &spr = wpnsbuf[QMisc.sprites[lava ? sprLAVADROWN : sprDROWN]];
1056 cs = spr.csets & 0xF;
1057 int32_t fr = spr.frames ? spr.frames : 1;
1058 int32_t spd = spr.speed ? spr.speed : 1;
1059 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1060 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1061 }
1062 37848162 return false;
1063 37848162 }
1064
1065 // Supplemental animation code that all derived classes should call
1066 // as a return value for animate().
1067 // Handles the death animation and returns true when enemy is finished.
1068 38512682 bool enemy::Dead(int32_t index)
1069 {
1070
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 38510853 times.
38512682 if(immortal)
1071 {
1072 1829 dying = false;
1073 1829 return false;
1074 }
1075
2/2
✓ Branch 0 taken 764663 times.
✓ Branch 1 taken 37746190 times.
38510853 if(dying)
1076 {
1077
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 764662 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
764663 if(deathexstate > -1 && deathexstate < 32)
1078 {
1079 1 setxmapflag(screen_spawned, 1<<deathexstate);
1080 1 deathexstate = -1;
1081 1 }
1082 764663 --clk2;
1083
1084
4/4
✓ Branch 0 taken 724726 times.
✓ Branch 1 taken 39937 times.
✓ Branch 2 taken 38687 times.
✓ Branch 3 taken 3242 times.
764663 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1085
2/2
✓ Branch 0 taken 41929 times.
✓ Branch 1 taken 682797 times.
724726 && hp>-1000) // not killed by ringleader
1086 38687 death_sfx();
1087
1088
2/2
✓ Branch 0 taken 721177 times.
✓ Branch 1 taken 43486 times.
764663 if(clk2==0)
1089 {
1090
2/2
✓ Branch 0 taken 42785 times.
✓ Branch 1 taken 701 times.
43486 if(flags&guy_never_return)
1091 701 never_return(screen_spawned, index);
1092
1093
2/2
✓ Branch 0 taken 43415 times.
✓ Branch 1 taken 71 times.
43486 if(leader)
1094 71 kill_em_all();
1095
1096 43486 leave_item();
1097 43486 }
1098
1099 764663 stop_bgsfx(index);
1100 764663 return (clk2==0);
1101 }
1102
1103 37746190 return false;
1104 38512682 }
1105
1106 // Basic animation code that all derived classes should call.
1107 // The one with an index is the one that is called by
1108 // the guys sprite list; index is the enemy's index in the list.
1109 37850785 bool enemy::animate(int32_t index)
1110 {
1111
2/2
✓ Branch 0 taken 1712365 times.
✓ Branch 1 taken 36138420 times.
37850785 if(sclk <= 0) hitdir = -1;
1112
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 37850529 times.
37850785 if(switch_hooked)
1113 {
1114
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1115 {
1116 //Run its script
1117 if (!didScriptThisFrame)
1118 {
1119 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1120 {
1121 return 0; //Avoid NULLPO if this object deleted itself
1122 }
1123 }
1124 }
1125 256 return false;
1126 }
1127
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 37850518 times.
37850529 if(do_falling(index)) return true;
1128
2/2
✓ Branch 0 taken 2356 times.
✓ Branch 1 taken 37848162 times.
37850518 else if(fallclk)
1129 {
1130 //clks
1131
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 704 times.
2356 if(hclk>0)
1132 704 --hclk;
1133
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(stunclk>0)
1134 --stunclk;
1135
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if ( frozenclock > 0 )
1136 --frozenclock;
1137
1/2
✓ Branch 0 taken 2356 times.
✗ Branch 1 not taken.
2356 if(hashero)
1138 {
1139 Hero.setX(x);
1140 Hero.setY(y);
1141 Hero.fallCombo = fallCombo;
1142 Hero.fallclk = fallclk;
1143
1144 if(hashero)
1145 {
1146 hashero = false; //Let Hero go if falling
1147 Hero.setEaten(0);
1148 }
1149 }
1150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2356 times.
2356 if (!didScriptThisFrame)
1151 {
1152 2356 run_script(MODE_NORMAL);
1153 2356 }
1154 2356 return false;
1155 }
1156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37848162 times.
37848162 if(do_drowning(index)) return true;
1157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37848162 times.
37848162 else if(drownclk)
1158 {
1159 //clks
1160 if(hclk>0)
1161 --hclk;
1162 if(stunclk>0)
1163 --stunclk;
1164 if ( frozenclock > 0 )
1165 --frozenclock;
1166 if(hashero)
1167 {
1168 Hero.setX(x);
1169 Hero.setY(y);
1170 Hero.drownclk = drownclk;
1171
1172 if(hashero)
1173 {
1174 hashero = false; //Let Hero go if falling
1175 Hero.setEaten(0);
1176 }
1177 }
1178 if (!didScriptThisFrame)
1179 {
1180 run_script(MODE_NORMAL);
1181 }
1182 return false;
1183 }
1184 37848162 int32_t nx = real_x(x);
1185 37848162 int32_t ny = real_y(y);
1186
1187
4/4
✓ Branch 0 taken 27369257 times.
✓ Branch 1 taken 10478905 times.
✓ Branch 2 taken 5634269 times.
✓ Branch 3 taken 21734988 times.
37848162 if(ox!=nx || oy!=ny)
1188 {
1189 16113174 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1190 16113174 }
1191
1192 37848162 ox = nx;
1193 37848162 oy = ny;
1194
1195 // Maybe they fell off the bottom in sideview, or were moved by a script.
1196
1197 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1198
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 37846333 times.
37848162 if ( immortal )
1199 {
1200 //skip, as it can go out of bounds, from immortality
1201 1829 }
1202
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 37846333 times.
✓ Branch 2 taken 37846333 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37846333 times.
37846333 else if ( (moveflags & move_ignore_screenedge) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1203 {
1204 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1205 }
1206
2/2
✓ Branch 0 taken 37814732 times.
✓ Branch 1 taken 31601 times.
37846333 else if (OUTOFBOUNDS(id, x, y))
1207 {
1208 31601 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1209 31601 }
1210 //fall down
1211
6/6
✓ Branch 0 taken 27030378 times.
✓ Branch 1 taken 10817784 times.
✓ Branch 2 taken 10547521 times.
✓ Branch 3 taken 27300641 times.
✓ Branch 4 taken 511501 times.
✓ Branch 5 taken 10036020 times.
37848162 if((enemycanfall(id) || (moveflags & move_obeys_grav) )&& fading != fade_flicker && clk>=0)
1212 {
1213
2/2
✓ Branch 0 taken 387698 times.
✓ Branch 1 taken 9648322 times.
10036020 if(isSideViewGravity())
1214 {
1215
1/2
✓ Branch 0 taken 387698 times.
✗ Branch 1 not taken.
387698 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1216 {
1217
2/2
✓ Branch 0 taken 230320 times.
✓ Branch 1 taken 157378 times.
387698 if(!isOnSideviewPlatform())
1218 {
1219 157378 bool willHitSVPlatform = false;
1220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH)?hit_width:16;
1221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT)?hit_height:16;
1222
2/2
✓ Branch 0 taken 157378 times.
✓ Branch 1 taken 157378 times.
314756 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1223 {
1224
5/8
✓ Branch 0 taken 23519 times.
✓ Branch 1 taken 133859 times.
✓ Branch 2 taken 23519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 157378 times.
✗ Branch 7 not taken.
157378 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1225 {
1226 willHitSVPlatform = true;
1227 break;
1228 }
1229 157378 }
1230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157378 times.
157378 if(willHitSVPlatform)
1231 {
1232 y+=fall/100;
1233 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1234 do_fix(y, 16); //Fix to top of SV Ladder
1235 fall = 0;
1236 }
1237 else
1238 {
1239 157378 y+=fall/100;
1240
2/2
✓ Branch 0 taken 17812 times.
✓ Branch 1 taken 139566 times.
157378 if(fall <= (int32_t)zinit.terminalv)
1241 139566 fall += (zinit.gravity/100);
1242 }
1243 157378 }
1244 else
1245 {
1246
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 230043 times.
230320 if(fall!=0) // Only fix pos once
1247 {
1248 //y-=(int32_t)y%8; // Fix position
1249 277 do_fix(y, 8); //Fix position
1250 277 }
1251
1252 230320 fall = 0;
1253 }
1254 387698 }
1255 else
1256 {
1257 if(isOnSideviewPlatform())
1258 fall = 0;
1259 else
1260 {
1261 zfix fall_amnt = fall/100;
1262 bool hit = false;
1263 while(fall_amnt >= 1)
1264 {
1265 --fall_amnt;
1266 ++y;
1267 if(isOnSideviewPlatform())
1268 {
1269 y = y.getInt();
1270 fall_amnt = 0;
1271 hit = true;
1272 break;
1273 }
1274 }
1275 if(fall_amnt > 0)
1276 y += fall_amnt;
1277 if(fall_amnt < 0)
1278 {
1279 if(!movexy(0,fall_amnt,spw_none,false,!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)))
1280 hit = true;
1281 }
1282 if(hit)
1283 fall = 0;
1284 else if(fall <= (int32_t)zinit.terminalv)
1285 fall += (zinit.gravity/100);
1286 }
1287 }
1288 387698 }
1289 else
1290 {
1291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9648322 times.
9648322 if (!(moveflags & move_no_fake_z))
1292 {
1293
2/2
✓ Branch 0 taken 5080259 times.
✓ Branch 1 taken 4568063 times.
9648322 if(fakefall!=0)
1294 4568063 fakez-=(fakefall/100);
1295
1296
2/2
✓ Branch 0 taken 4568063 times.
✓ Branch 1 taken 5080259 times.
9648322 if(fakez<0)
1297 4568063 fakez = fakefall = 0;
1298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5080259 times.
5080259 else if(fakefall <= (int32_t)zinit.terminalv)
1299 5080259 fakefall += (zinit.gravity/100);
1300
1301
5/6
✓ Branch 0 taken 9648322 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5080259 times.
✓ Branch 3 taken 4568063 times.
✓ Branch 4 taken 4582310 times.
✓ Branch 5 taken 497949 times.
9648322 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1302 9648322 }
1303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9648322 times.
9648322 if (!(moveflags & move_no_real_z))
1304 {
1305
2/2
✓ Branch 0 taken 5513145 times.
✓ Branch 1 taken 4135177 times.
9648322 if(fall!=0)
1306 4135177 z-=(fall/100);
1307
1308
2/2
✓ Branch 0 taken 4120605 times.
✓ Branch 1 taken 5527717 times.
9648322 if(z<0)
1309 4120605 z = fall = 0;
1310
2/2
✓ Branch 0 taken 10057 times.
✓ Branch 1 taken 5517660 times.
5527717 else if(fall <= (int32_t)zinit.terminalv)
1311 5517660 fall += (zinit.gravity/100);
1312
1313
6/6
✓ Branch 0 taken 9606108 times.
✓ Branch 1 taken 42214 times.
✓ Branch 2 taken 5485503 times.
✓ Branch 3 taken 4120605 times.
✓ Branch 4 taken 4990689 times.
✓ Branch 5 taken 494814 times.
9648322 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1314 9648322 }
1315
1316 }
1317 10036020 }
1318
4/4
✓ Branch 0 taken 37332695 times.
✓ Branch 1 taken 515467 times.
✓ Branch 2 taken 9227963 times.
✓ Branch 3 taken 28104732 times.
37848162 if(!isSideViewGravity() && (moveflags & move_can_pitfall))
1319 {
1320
8/10
✓ Branch 0 taken 9201231 times.
✓ Branch 1 taken 26732 times.
✓ Branch 2 taken 9161573 times.
✓ Branch 3 taken 39658 times.
✓ Branch 4 taken 9161573 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9201231 times.
✓ Branch 8 taken 9161573 times.
✓ Branch 9 taken 9161573 times.
9227963 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1321 {
1322 9161573 fallCombo = check_pits();
1323 9161573 }
1324 27551109 }
1325
4/4
✓ Branch 0 taken 37332695 times.
✓ Branch 1 taken 18838613 times.
✓ Branch 2 taken 146897 times.
✓ Branch 3 taken 37185798 times.
56171308 if(!isSideViewGravity() && (moveflags & move_can_waterdrown))
1326 {
1327
8/10
✓ Branch 0 taken 142951 times.
✓ Branch 1 taken 3946 times.
✓ Branch 2 taken 141898 times.
✓ Branch 3 taken 1053 times.
✓ Branch 4 taken 141898 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 142951 times.
✓ Branch 8 taken 141898 times.
✓ Branch 9 taken 141898 times.
146897 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1328 {
1329 141898 drownCombo = check_water();
1330 141898 }
1331 430693 }
1332
1333 56455104 runKnockback(); //scripted knockback handling
1334
1335 // clk is incremented here
1336
2/2
✓ Branch 0 taken 54161643 times.
✓ Branch 1 taken 2293461 times.
56455104 if(++clk >= frate)
1337 2293461 clk=0;
1338
1339 // hit and death handling
1340
2/2
✓ Branch 0 taken 1250848 times.
✓ Branch 1 taken 55204256 times.
56455104 if(hclk>0)
1341 1250848 --hclk;
1342
1343
2/2
✓ Branch 0 taken 675698 times.
✓ Branch 1 taken 55779406 times.
56455104 if(stunclk>0)
1344 675698 --stunclk;
1345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56455104 times.
56455104 if ( frozenclock > 0 )
1346 --frozenclock;
1347
1348
5/6
✓ Branch 0 taken 14876 times.
✓ Branch 1 taken 56440228 times.
✓ Branch 2 taken 124 times.
✓ Branch 3 taken 14752 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 124 times.
56455104 if(ceiling && z <= 0 && fakez <= 0)
1349 124 ceiling = false;
1350
1351 56455104 try_death();
1352
1353 56455104 scored=false;
1354
1355 56455104 ++c_clk;
1356
1357 //Run its script
1358
2/2
✓ Branch 0 taken 18631759 times.
✓ Branch 1 taken 37823345 times.
56455104 if (!didScriptThisFrame)
1359 {
1360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37823345 times.
37823345 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1361 {
1362 return 0; //Avoid NULLPO if this object deleted itself
1363 }
1364 37823345 }
1365
1366 // returns true when enemy is defeated
1367 56455104 return Dead(index);
1368 56457727 }
1369
1370 38599060 bool enemy::setSolid(bool set)
1371 {
1372
1/2
✓ Branch 0 taken 38599060 times.
✗ Branch 1 not taken.
38599060 bool actual = set && !isSubmerged();
1373 38599060 bool ret = solid_object::setSolid(actual);
1374 38599060 solid = set;
1375 38599060 return ret;
1376 }
1377 void enemy::doContactDamage(int32_t hdir)
1378 {
1379 Hero.hithero(guys.find(this), hdir);
1380 }
1381
1382 22405 void enemy::solid_push(solid_object *obj)
1383 {
1384
1/2
✓ Branch 0 taken 22405 times.
✗ Branch 1 not taken.
22405 if(obj == this) return; //can't push self
1385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22405 times.
22405 if(moveflags&move_not_pushable) return; //not pushable
1386 22405 zfix dx, dy;
1387 22405 int32_t hdir = -1;
1388 22405 solid_push_int(obj,dx,dy,hdir,true);
1389
1390
4/4
✓ Branch 0 taken 22292 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 150 times.
✓ Branch 3 taken 22142 times.
22405 if(!dx && !dy) return;
1391
1392 263 bool t = obj->getTempNonsolid();
1393 263 obj->setTempNonsolid(true);
1394
1395 263 int32_t ydir = dy > 0 ? down : up;
1396 263 int32_t xdir = dx > 0 ? right : left;
1397
1398 263 auto special = isflier(id) ? spw_floater : spw_none;
1399
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 7 times.
263 if(!movexy(dx,dy,special,true,true))
1400 {
1401 //Crushed?
1402 7 }
1403
1404 263 obj->setTempNonsolid(t);
1405 22405 }
1406 22405 bool enemy::is_unpushable() const
1407 {
1408 22405 return isSubmerged();
1409 }
1410 22087 bool enemy::sideview_mode() const
1411 {
1412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22087 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22087 return isSideViewGravity() && (moveflags&move_obeys_grav) && !(moveflags&move_not_pushable);
1413 }
1414
1415 3234 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1416 {
1417 3234 int32_t yg = (special==spw_floater)?8:0;
1418 3234 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1419
1420
8/10
✓ Branch 0 taken 2364 times.
✓ Branch 1 taken 870 times.
✓ Branch 2 taken 814 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 870 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 870 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2368 times.
✓ Branch 9 taken 3238 times.
3234 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1421 4732 return true;
1422
1423 3238 bool isInDungeon = isdungeon(screen_spawned);
1424
3/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 2976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 262 times.
3238 if(isInDungeon || special==spw_wizzrobe)
1425 {
1426
7/8
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 604 times.
✓ Branch 5 taken 1779 times.
✓ Branch 6 taken 604 times.
✗ Branch 7 not taken.
2976 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1427 1199 return true;
1428
1429
7/8
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 1187 times.
✓ Branch 2 taken 595 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 595 times.
✓ Branch 5 taken 595 times.
✓ Branch 6 taken 595 times.
✗ Branch 7 not taken.
1779 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1430
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
1190 if(special!=spw_door) // walk in door way
1431 return true;
1432 595 }
1433
1434
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 795 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
857 if(!(moveflags & move_can_pitwalk) && !(moveflags & move_can_pitfall)) //Don't walk into pits (knockback doesn't call this func)
1435 {
1436
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1437
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1438 return true;
1439 62 }
1440
1441
1/4
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
857 switch(special)
1442 {
1443 case spw_clipbottomright:
1444 if(dy>=128 || dx>=208) return true;
1445 break;
1446 case spw_clipright:
1447 break; //if(x>=208) return true; break;
1448
1449 case spw_wizzrobe: // fall through
1450 case spw_floater: // Special case for fliers and wizzrobes - hack!
1451 {
1452
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 595 times.
857 if(isInDungeon)
1453 {
1454
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dy < 32-yg || dy >= 144) return true;
1455
2/4
✓ Branch 0 taken 595 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 595 times.
595 if(dx < 32 || dx >= 224) return true;
1456 595 }
1457 857 return false;
1458 }
1459 }
1460
1461 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1462 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1463
1464 if(special==spw_water)
1465 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1466
1467 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1468 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1469 870 }
1470
1471 6563 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1472 {
1473 6563 bool kb = false;
1474 6563 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1475
1476
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 6563 times.
✓ Branch 2 taken 6563 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6563 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6563 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 6563 times.
6563 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1477 return true;
1478
1479
2/2
✓ Branch 0 taken 5050 times.
✓ Branch 1 taken 1513 times.
6563 if(isdungeon(screen_spawned))
1480 {
1481
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dy<32) || (dy>=world_h-32))
1482 return true;
1483
1484
2/4
✓ Branch 0 taken 1513 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1513 times.
1513 if((dx<32) || (dx>=world_w-32))
1485 return true;
1486 1513 }
1487
1488
2/4
✓ Branch 0 taken 6563 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6563 times.
6563 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall))) //Don't walk into pits, unless being knocked back
1489 {
1490
2/4
✓ Branch 0 taken 6563 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6563 times.
13126 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1491
2/4
✓ Branch 0 taken 6563 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6563 times.
✗ Branch 3 not taken.
6563 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1492 return true;
1493 6563 }
1494
1495
2/2
✓ Branch 0 taken 6533 times.
✓ Branch 1 taken 30 times.
6563 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1496 {
1497
3/4
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 3888 times.
✓ Branch 2 taken 2645 times.
✗ Branch 3 not taken.
9178 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2645 times.
2645 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1499 }
1500 else
1501 {
1502
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
60 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1503
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1504
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
30 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1506 }
1507 6563 }
1508
1509 // returns true if cannot walk
1510 32494855 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1511 {
1512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32494855 times.
32494855 if(moveflags & move_new_movement)
1513 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1514 32494855 int32_t yg = (special==spw_floater)?8:0;
1515 32494855 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1516
2/2
✓ Branch 0 taken 3720556 times.
✓ Branch 1 taken 28774299 times.
32494855 switch(dir)
1517 {
1518 case l_down:
1519 case r_down:
1520 case down:
1521 case 11: //r_down
1522 case 12: //down
1523 case 13: //l_down
1524 {
1525
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3720556 times.
3720556 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1526 {
1527
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3720548 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
3720556 if ( SIZEflags&OVERRIDE_HIT_HEIGHT && !isflier(id) )
1528 {
1529 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1530
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 dy += zc_max(hit_height-16,0);
1531 8 }
1532 3720556 }
1533 3720556 break;
1534 }
1535 }
1536
2/2
✓ Branch 0 taken 3722962 times.
✓ Branch 1 taken 28771893 times.
32494855 switch(dir)
1537 {
1538 case r_up:
1539 case r_down:
1540 case right:
1541 case 9: //r_up
1542 case 10: //right
1543 case 11: //r_down
1544 {
1545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3722962 times.
3722962 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1546 {
1547
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3722959 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3722962 if ( SIZEflags&OVERRIDE_HIT_WIDTH && !isflier(id) )
1548 {
1549 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1550
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dx += zc_max(hit_width-16,0);
1551 3 }
1552 3722962 }
1553 3722962 break;
1554 }
1555 }
1556
1557
10/10
✓ Branch 0 taken 22402108 times.
✓ Branch 1 taken 10092747 times.
✓ Branch 2 taken 8743350 times.
✓ Branch 3 taken 1349397 times.
✓ Branch 4 taken 10055594 times.
✓ Branch 5 taken 37153 times.
✓ Branch 6 taken 10032428 times.
✓ Branch 7 taken 23166 times.
✓ Branch 8 taken 22454949 times.
✓ Branch 9 taken 32487377 times.
32494855 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=world_w-16+nb || dy>=world_h-16+nb)
1558 44917376 return true;
1559
1560 32487377 bool isInDungeon = isdungeon(screen_spawned);
1561
4/4
✓ Branch 0 taken 3965618 times.
✓ Branch 1 taken 28521759 times.
✓ Branch 2 taken 11756 times.
✓ Branch 3 taken 3953862 times.
32487377 if(isInDungeon || special==spw_wizzrobe)
1562 {
1563
8/8
✓ Branch 0 taken 5892236 times.
✓ Branch 1 taken 22641279 times.
✓ Branch 2 taken 5667745 times.
✓ Branch 3 taken 224491 times.
✓ Branch 4 taken 5820349 times.
✓ Branch 5 taken 17045421 times.
✓ Branch 6 taken 5820162 times.
✓ Branch 7 taken 187 times.
28533515 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=world_h-32 && dy>=world_h-32))
1564 11487907 return true;
1565
1566
8/8
✓ Branch 0 taken 5739852 times.
✓ Branch 1 taken 11305756 times.
✓ Branch 2 taken 5573332 times.
✓ Branch 3 taken 166520 times.
✓ Branch 4 taken 5688285 times.
✓ Branch 5 taken 5783991 times.
✓ Branch 6 taken 5687331 times.
✓ Branch 7 taken 954 times.
17045608 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<world_w-32 && dx>=world_w-32))
1567
2/2
✓ Branch 0 taken 113905 times.
✓ Branch 1 taken 94 times.
11260663 if(special!=spw_door) // walk in door way
1568 113905 return true;
1569 5785039 }
1570
1571
6/6
✓ Branch 0 taken 3098671 times.
✓ Branch 1 taken 6640230 times.
✓ Branch 2 taken 750815 times.
✓ Branch 3 taken 2347856 times.
✓ Branch 4 taken 51230 times.
✓ Branch 5 taken 699585 times.
9738901 if(!(moveflags & move_can_pitwalk) && (!(moveflags & move_can_pitfall) || !kb)) //Don't walk into pits, unless being knocked back
1572 {
1573
4/4
✓ Branch 0 taken 3041024 times.
✓ Branch 1 taken 6417 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 3040072 times.
6087563 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1574
4/4
✓ Branch 0 taken 3040841 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 3040122 times.
✓ Branch 3 taken 719 times.
3041024 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1575 7369 return true;
1576 3040072 }
1577
1578
4/4
✓ Branch 0 taken 7548417 times.
✓ Branch 1 taken 2176861 times.
✓ Branch 2 taken 973 times.
✓ Branch 3 taken 5281 times.
9731532 switch(special)
1579 {
1580 case spw_clipbottomright:
1581
4/4
✓ Branch 0 taken 786 times.
✓ Branch 1 taken 187 times.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 707 times.
973 if(dy>=world_h-48 || dx>=world_w-48) return true;
1582 707 break;
1583 case spw_clipright:
1584 5281 break; //if(input_x>=208) return true; break;
1585
1586 case spw_wizzrobe: // fall through
1587 case spw_floater: // Special case for fliers and wizzrobes - hack!
1588 {
1589
2/2
✓ Branch 0 taken 2906738 times.
✓ Branch 1 taken 4641679 times.
7548417 if(isInDungeon)
1590 {
1591
3/4
✓ Branch 0 taken 4641667 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4641667 times.
4641679 if(dy < 32-yg || dy >= world_h-32) return true;
1592
4/4
✓ Branch 0 taken 4639555 times.
✓ Branch 1 taken 2112 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4639539 times.
4641667 if(dx < 32 || dx >= world_w-32) return true;
1593 4639539 }
1594 7546277 return false;
1595 }
1596 }
1597
1598 2182849 dx = CLEAR_LOW_BITS(dx, special == spw_halfstep ? 3 : 4);
1599
2/2
✓ Branch 0 taken 486589 times.
✓ Branch 1 taken 1696260 times.
2182849 dy = CLEAR_LOW_BITS(dy, special == spw_halfstep || isSideViewGravity() ? 3 : 4);
1600
1601
2/2
✓ Branch 0 taken 414677 times.
✓ Branch 1 taken 1768172 times.
2182849 if(special==spw_water)
1602
2/2
✓ Branch 0 taken 16749 times.
✓ Branch 1 taken 397928 times.
414677 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1603
1604
2/2
✓ Branch 0 taken 1708136 times.
✓ Branch 1 taken 60036 times.
1768172 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1605 {
1606
4/4
✓ Branch 0 taken 1226092 times.
✓ Branch 1 taken 482044 times.
✓ Branch 2 taken 1216055 times.
✓ Branch 3 taken 10037 times.
2924191 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1607
2/2
✓ Branch 0 taken 14580 times.
✓ Branch 1 taken 1201475 times.
1216055 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1608 }
1609 else
1610 {
1611
4/4
✓ Branch 0 taken 42909 times.
✓ Branch 1 taken 17127 times.
✓ Branch 2 taken 42645 times.
✓ Branch 3 taken 264 times.
102681 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1612
3/4
✓ Branch 0 taken 42282 times.
✓ Branch 1 taken 363 times.
✓ Branch 2 taken 42282 times.
✗ Branch 3 not taken.
42645 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1613
4/4
✓ Branch 0 taken 37047 times.
✓ Branch 1 taken 5235 times.
✓ Branch 2 taken 37032 times.
✓ Branch 3 taken 15 times.
42282 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1614
2/2
✓ Branch 0 taken 36729 times.
✓ Branch 1 taken 303 times.
37032 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1615 }
1616 10118383 }
1617
1618 496901 bool enemy::isOnSideviewPlatform()
1619 {
1620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
1621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
496901 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1622
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 496901 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
496901 if(!get_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP)&&fall<0)
1623 return false;
1624
5/6
✓ Branch 0 taken 11630 times.
✓ Branch 1 taken 485271 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 11208 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 422 times.
496901 if(y + usehei >= world_h && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) return true; //Bottom of the map
1625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 496479 times.
496479 if(check_slope(x, y+1, usewid, usehei)) return true;
1626
2/2
✓ Branch 0 taken 496479 times.
✓ Branch 1 taken 215641 times.
712120 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1627 {
1628
2/2
✓ Branch 0 taken 215641 times.
✓ Branch 1 taken 280838 times.
496479 if(_walkflag(nx,y+usehei,1)) return true;
1629
3/4
✓ Branch 0 taken 215641 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151313 times.
✓ Branch 3 taken 64328 times.
215641 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64328 times.
64328 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1631 64328 }
1632 215641 return false;
1633 496901 }
1634
1635 // Stops playing the given sound only if there are no enemies left to play it
1636 767571 void enemy::stop_bgsfx(int32_t index)
1637 {
1638
2/2
✓ Branch 0 taken 752500 times.
✓ Branch 1 taken 15071 times.
767571 if(bgsfx<=0)
1639 752500 return;
1640
1641 // Look for other enemies with the same bgsfx
1642
2/2
✓ Branch 0 taken 52954 times.
✓ Branch 1 taken 8767 times.
61721 for(int32_t i=0; i<guys.Count(); i++)
1643 {
1644
4/4
✓ Branch 0 taken 41901 times.
✓ Branch 1 taken 11053 times.
✓ Branch 2 taken 6304 times.
✓ Branch 3 taken 35597 times.
52954 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1645 6304 return;
1646 46650 }
1647
1648 8767 stop_sfx(bgsfx);
1649 767571 }
1650
1651
1652 // to allow for different sfx on defeating enemy
1653 40308 void enemy::death_sfx()
1654 {
1655
2/2
✓ Branch 0 taken 40023 times.
✓ Branch 1 taken 285 times.
40308 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1656 40308 }
1657
1658 void enemy::move(zfix dx,zfix dy)
1659 {
1660 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & move_obeys_grav) || !enemycanfall(id)))
1661 {
1662 x+=dx;
1663 y+=dy;
1664 }
1665 }
1666
1667 18327114 void enemy::move(zfix s)
1668 {
1669
9/10
✓ Branch 0 taken 18327075 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 109109 times.
✓ Branch 3 taken 18217966 times.
✓ Branch 4 taken 58221 times.
✓ Branch 5 taken 50888 times.
✓ Branch 6 taken 1005 times.
✓ Branch 7 taken 57216 times.
✓ Branch 8 taken 1005 times.
✗ Branch 9 not taken.
18327114 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & move_obeys_grav)))
1670 {
1671 18326070 sprite::move(s);
1672 18326070 }
1673 18327114 }
1674
1675 43785 void enemy::leave_item()
1676 {
1677 43785 int32_t drop_item = select_dropitem(item_set, x, y);
1678 43785 int32_t thedropset = item_set;
1679
1680 43785 std::vector<int32_t> &ev = FFCore.eventData;
1681 43785 ev.clear();
1682 43785 ev.push_back(getUID());
1683 43785 ev.push_back(drop_item*10000);
1684 43785 ev.push_back(thedropset*10000);
1685
1686 43785 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1687 43785 drop_item = vbound(ev[1] / 10000,-2,255);
1688 43785 thedropset = ev[2] / 10000;
1689 43785 ev.clear();
1690
1/2
✓ Branch 0 taken 43785 times.
✗ Branch 1 not taken.
43785 if(drop_item == -2)
1691 {
1692 drop_item = select_dropitem(thedropset,x,y);
1693 }
1694
1695
6/6
✓ Branch 0 taken 16531 times.
✓ Branch 1 taken 27254 times.
✓ Branch 2 taken 916 times.
✓ Branch 3 taken 15615 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 747 times.
43785 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1696 {
1697 item* itm;
1698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16362 times.
16362 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1699 {
1700 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1701 }
1702 else
1703 {
1704
8/14
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 14642 times.
✓ Branch 2 taken 1720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1720 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1720 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1720 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1720 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1720 times.
✗ Branch 13 not taken.
16362 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1705
4/8
✓ Branch 0 taken 14642 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14642 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14642 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14642 times.
✗ Branch 7 not taken.
14642 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1706 }
1707 16362 itm->from_dropset = thedropset;
1708 16362 add_item_for_screen(screen_spawned, itm);
1709
1710 16362 ev.push_back(getUID());
1711 16362 ev.push_back(itm->getUID());
1712
1713 16362 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1714 16362 ev.clear();
1715 16362 }
1716 43785 }
1717
1718 // auomatically kill off enemy (for rooms with ringleaders)
1719 411 void enemy::kickbucket()
1720 {
1721
3/4
✓ Branch 0 taken 379 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 379 times.
✗ Branch 3 not taken.
411 if(!superman && !(flags&guy_ignore_kill_all))
1722 379 hp=-1000; // don't call death_sfx()
1723 411 }
1724
1725 21250 bool enemy::isSubmerged() const
1726 {
1727 21250 return submerged;
1728 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1729 }
1730
1731 20952 void enemy::FireBreath(bool seekhero)
1732 {
1733
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if(wpn==wNone)
1734 return;
1735
1736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20952 times.
20952 if(wpn==ewFireTrail)
1737 {
1738 dmisc1 = e1tEACHTILE;
1739 FireWeapon();
1740 return;
1741 }
1742
1743 20952 float fire_angle=0.0;
1744 20952 int32_t wx=0, wy=0, wdir=dir, xoff=0, yoff=0;
1745
1746
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1747 {
1748 xoff += hxofs;
1749 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1750 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1751 else
1752 xoff += (hit_width / 2) - 8;
1753 }
1754
1/2
✓ Branch 0 taken 20952 times.
✗ Branch 1 not taken.
20952 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1755 {
1756 yoff += hyofs;
1757 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1758 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1759 else
1760 yoff += (hit_height / 2) - 8;
1761 }
1762
1763
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 if(!seekhero)
1764 {
1765
4/5
✓ Branch 0 taken 3297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3079 times.
✓ Branch 3 taken 5287 times.
✓ Branch 4 taken 4208 times.
15871 switch(dir)
1766 {
1767 case down:
1768 3079 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1769 3079 wx=x;
1770 3079 wy=y+8;
1771 3079 break;
1772
1773 case -1:
1774 case up:
1775 3297 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1776 3297 wx=x;
1777 3297 wy=y-8;
1778 3297 break;
1779
1780 case left:
1781 5287 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1782 5287 wx=x-8;
1783 5287 wy=y;
1784 5287 break;
1785
1786 case right:
1787 4208 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1788 4208 wx=x+8;
1789 4208 wy=y;
1790 4208 break;
1791 }
1792
1793
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 15735 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
15871 if(wpn==ewFlame || wpn==ewFlame2)
1794 {
1795
2/4
✓ Branch 0 taken 15735 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15735 times.
15735 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==-PI/2) wdir=up;
1797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==PI/2) wdir=down;
1798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle==0) wdir=right;
1799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<-PI/2) wdir=l_up;
1800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15735 times.
15735 else if(fire_angle<0) wdir=r_up;
1801
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14237 times.
15735 else if(fire_angle<(PI/2)) wdir=r_down;
1802
2/2
✓ Branch 0 taken 10121 times.
✓ Branch 1 taken 4116 times.
14237 else if(fire_angle<PI) wdir=l_down;
1803 15735 }
1804 15871 }
1805 else
1806 {
1807 5081 wx = x;
1808 5081 wy = y;
1809 }
1810
1811
2/2
✓ Branch 0 taken 5081 times.
✓ Branch 1 taken 15871 times.
20952 addEwpn(wx+xoff,wy+yoff,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1812 20952 sfx(wpnsfx(wpn),pan(int32_t(x)));
1813
1814 20952 int32_t i=Ewpns.Count()-1;
1815 20952 weapon *ew = (weapon*)(Ewpns.spr(i));
1816 20952 ew->moveflags &= ~move_can_pitfall; //No falling in pits
1817
1818
4/4
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 5081 times.
✓ Branch 2 taken 7914 times.
✓ Branch 3 taken 7957 times.
20952 if(!seekhero && (zc_oldrand()&4))
1819 {
1820 7957 ew->angular=true;
1821 7957 ew->angle=fire_angle;
1822 7957 }
1823
1824
4/4
✓ Branch 0 taken 20676 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 20359 times.
20952 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1825 {
1826 20359 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20359 times.
20359 if ( ew->do_animation ) ew->tile+=ew->aframe;
1828 20359 }
1829
1830
2/2
✓ Branch 0 taken 20952 times.
✓ Branch 1 taken 766199 times.
787151 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1831 {
1832 766199 Ewpns.swap(j,j-1);
1833 766199 }
1834 20952 }
1835
1836 44646 void enemy::FireWeapon()
1837 {
1838 /*
1839 * Type:
1840 * 0x01: Boss fireball
1841 * 0x02: Seeks Hero
1842 * 0x04: Fast projectile
1843 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1844 */
1845
1846
2/2
✓ Branch 0 taken 44515 times.
✓ Branch 1 taken 131 times.
44646 if (wpn < 1) return;
1847
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 44515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
44515 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1848 return;
1849
1850
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44515 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44515 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1851 dmisc1 = e1tEACHTILE;
1852
1853 44515 int32_t xoff = 0;
1854 44515 int32_t yoff = 0;
1855
1/2
✓ Branch 0 taken 44515 times.
✗ Branch 1 not taken.
44515 if (SIZEflags & OVERRIDE_HIT_WIDTH)
1856 {
1857 xoff += hxofs;
1858 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
1859 xoff += (hit_width / 2) - (weap_data.tilew * 8);
1860 else
1861 xoff += (hit_width / 2) - 8;
1862 }
1863
1/2
✓ Branch 0 taken 44515 times.
✗ Branch 1 not taken.
44515 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
1864 {
1865 yoff += hyofs;
1866 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
1867 yoff += (hit_height / 2) - (weap_data.tileh * 8);
1868 else
1869 yoff += (hit_height / 2) - 8;
1870 }
1871
1872 // TODO(crash): check that .add succeeds.
1873
1874
5/8
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 41516 times.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 416 times.
✓ Branch 5 taken 98 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
44515 switch(dmisc1)
1875 {
1876 case e1t5SHOTS: //BS-Aquamentus
1877 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1878 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1879 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1880 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1881
1882 [[fallthrough]];
1883 case e1t3SHOTSFAST:
1884 case e1t3SHOTS: //Aquamentus
1885
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1886 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1887
7/14
✓ Branch 0 taken 646 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 646 times.
✗ Branch 13 not taken.
646 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1888 646 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1889
1890 [[fallthrough]];
1891 default:
1892
12/20
✓ Branch 0 taken 42162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42162 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42162 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 42162 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 42157 times.
✓ Branch 12 taken 42162 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18238 times.
✓ Branch 15 taken 23924 times.
✓ Branch 16 taken 42162 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 42162 times.
✗ Branch 19 not taken.
42162 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1893 42162 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1894 42162 sfx(wpnsfx(wpn),pan(int32_t(x)));
1895 42162 break;
1896
1897 case e1tSLANT:
1898 {
1899 416 int32_t slant = 0;
1900
1901
10/10
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 161 times.
✓ Branch 6 taken 61 times.
✓ Branch 7 taken 316 times.
✓ Branch 8 taken 138 times.
✓ Branch 9 taken 178 times.
416 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1902 246 slant = left;
1903
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 33 times.
✓ Branch 6 taken 55 times.
✓ Branch 7 taken 86 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 61 times.
178 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1904 117 slant = right;
1905
1906
9/18
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 330 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 330 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 330 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 330 times.
✓ Branch 14 taken 330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 330 times.
✗ Branch 17 not taken.
330 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1907 330 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1908 330 sfx(wpnsfx(wpn),pan(int32_t(x)));
1909 330 break;
1910 }
1911
1912 case e1t8SHOTS: //Fire Wizzrobe
1913
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1914 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1915 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1916
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1917 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1918 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1919
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1920 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1921 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1922
7/14
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 98 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 98 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 98 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 98 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 98 times.
✗ Branch 13 not taken.
98 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1923 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1924 98 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1925
1926 [[fallthrough]];
1927 case e1t4SHOTS: //Stalfos 3
1928
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1929 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1930 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1931
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1932 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1933 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1934
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1935 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1936 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1937
7/14
✓ Branch 0 taken 1937 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1937 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1937 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1937 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1937 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1937 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1937 times.
✗ Branch 13 not taken.
1937 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1938 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1939 1937 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
1940 1937 sfx(wpnsfx(wpn),pan(int32_t(x)));
1941 1937 break;
1942
1943 case e1tSUMMON: // Bat Wizzrobe
1944 {
1945 if(dmisc4==0) break; // Summon 0
1946
1947 int32_t bc=0;
1948
1949 for(int32_t gc=0; gc<guys.Count(); gc++)
1950 {
1951 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1952 {
1953 ++bc;
1954 }
1955 }
1956
1957 if(bc<=40) // Not too many enemies
1958 {
1959 int32_t kids = guys.Count();
1960 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1961
1962 for(int32_t i=0; i<bats; i++)
1963 {
1964 if(addchild(screen_spawned,x,y,dmisc3,-10, this))
1965 {
1966 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1967 }
1968 }
1969
1970 sfx(firesfx, pan(int32_t(x)));
1971 }
1972
1973 break;
1974 }
1975
1976 case e1tSUMMONLAYER: // Summoner
1977 {
1978 if(count_layer_enemies(screen_spawned)==0)
1979 {
1980 break;
1981 }
1982
1983 int32_t kids = guys.Count();
1984
1985 if(kids<40)
1986 {
1987 int32_t newguys=(zc_oldrand()%3)+1;
1988 bool summoned=false;
1989
1990 for(int32_t i=0; i<newguys; i++)
1991 {
1992 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
1993 int32_t x2=0;
1994 int32_t y2=0;
1995
1996 for(int32_t k=0; k<20; ++k)
1997 {
1998 x2=16*((zc_oldrand()%12)+2);
1999 y2=16*((zc_oldrand()%7)+2);
2000
2001 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2002 {
2003 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
2004 {
2005 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2006 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
2007 {
2008 ((enemy*)guys.spr(kids+i))->fakez = 64;
2009 ((enemy*)guys.spr(kids+i))->z = 0;
2010 }
2011 }
2012
2013 summoned=true;
2014 break;
2015 }
2016 }
2017 }
2018
2019 if(summoned)
2020 {
2021 sfx(firesfx, pan(int32_t(x)));
2022 }
2023 }
2024
2025 break;
2026 }
2027 }
2028 44560 }
2029
2030
2031 // Hit the shield(s)?
2032 // Apparently, this function is only used for hookshots...
2033 2767 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2034 {
2035
6/6
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1791 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 141 times.
✓ Branch 5 taken 834 times.
2767 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2036 834 return false;
2037
2038 1933 bool ret = false;
2039
2040 // TODO: There must be some bitwise operations that can simplify this...
2041
9/12
✓ Branch 0 taken 1207 times.
✓ Branch 1 taken 726 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 683 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 16 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 699 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 699 times.
✓ Branch 10 taken 699 times.
✗ Branch 11 not taken.
1933 if(wpny > y) ret = ((flags&guy_shield_front && xdir==down) || (flags&guy_shield_back && xdir==up) || (flags&guy_shield_left && xdir==left) || (flags&guy_shield_right && xdir==right));
2042
9/12
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 824 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 778 times.
✓ Branch 4 taken 33 times.
✓ Branch 5 taken 13 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 811 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 811 times.
✓ Branch 10 taken 811 times.
✗ Branch 11 not taken.
1207 else if(wpny < y) ret = ((flags&guy_shield_front && xdir==up) || (flags&guy_shield_back && xdir==down) || (flags&guy_shield_left && xdir==right) || (flags&guy_shield_right && xdir==left));
2043
2044
11/14
✓ Branch 0 taken 1065 times.
✓ Branch 1 taken 868 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 849 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 825 times.
✓ Branch 6 taken 9 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 840 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 840 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 840 times.
1933 if(wpnx < x) ret = ret || ((flags&guy_shield_front && xdir==left) || (flags&guy_shield_back && xdir==right) || (flags&guy_shield_left && xdir==down) || (flags&guy_shield_right && xdir==up));
2045
11/14
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 863 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 827 times.
✓ Branch 6 taken 19 times.
✓ Branch 7 taken 17 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 844 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 844 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 844 times.
1065 else if(wpnx > x) ret = ret || ((flags&guy_shield_front && xdir==right) || (flags&guy_shield_back && xdir==left) || (flags&guy_shield_left && xdir==up) || (flags&guy_shield_right && xdir==down));
2046
2047 1933 return ret;
2048 2767 }
2049
2050
2051 //! Weapon Editor for 2.6
2052 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2053
2054
2055 //converts a wqeapon ID to its defence index.
2056 127255 int32_t weaponToDefence(int32_t wid)
2057 {
2058
23/47
✗ Branch 0 not taken.
✓ Branch 1 taken 64672 times.
✓ Branch 2 taken 9322 times.
✓ Branch 3 taken 25021 times.
✓ Branch 4 taken 4211 times.
✓ Branch 5 taken 37 times.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3160 times.
✓ Branch 9 taken 9836 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 269 times.
✓ Branch 13 taken 1438 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 512 times.
✓ Branch 17 taken 1459 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2054 times.
✓ Branch 20 taken 2767 times.
✓ Branch 21 taken 610 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 240 times.
✓ Branch 24 taken 469 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 19 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 28 times.
✗ Branch 31 not taken.
✓ Branch 32 taken 12 times.
✓ Branch 33 taken 77 times.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✓ Branch 39 taken 993 times.
✗ Branch 40 not taken.
✗ Branch 41 not taken.
✓ Branch 42 taken 1 times.
✗ Branch 43 not taken.
✗ Branch 44 not taken.
✗ Branch 45 not taken.
✗ Branch 46 not taken.
127255 switch(wid)
2059 {
2060 case wNone: return -1;
2061 64672 case wSword: return edefSWORD;
2062 9322 case wBeam: return edefBEAM;
2063 25021 case wBrang: return edefBRANG;
2064 4211 case wBomb: return edefBOMB;
2065 37 case wSBomb: return edefSBOMB;
2066 48 case wLitBomb: return edefBOMB;
2067 case wLitSBomb: return edefSBOMB;
2068 3160 case wArrow: return edefARROW;
2069 9836 case wFire: return edefFIRE;
2070 case wWhistle:
2071 {
2072 return edefWhistle;
2073 }
2074 case wBait: return edefBAIT;
2075 269 case wWand: return edefWAND;
2076 1438 case wMagic: return edefMAGIC;
2077 case wCatching: return -1;
2078 case wWind: return edefWIND;
2079 512 case wRefMagic: return edefREFMAGIC;
2080 1459 case wRefFireball: return edefREFBALL;
2081 case wRefRock: return edefREFROCK;
2082 2054 case wHammer: return edefHAMMER;
2083 2767 case wHookshot: return edefHOOKSHOT;
2084 610 case wHSHandle: return edefHOOKSHOT;
2085 case wHSChain: return edefHOOKSHOT;
2086 240 case wSSparkle: return edefSPARKLE;
2087 469 case wFSparkle: return edefSPARKLE;
2088 case wSmack: return -1; // is this the candle object?
2089 case wPhantom: return -1; //engine created visual effects.
2090 case wCByrna: return edefBYRNA;
2091 19 case wRefBeam: return edefREFBEAM;
2092 case wStomp: return edefSTOMP;
2093 28 case wScript1: return edefSCRIPT01;
2094 case wScript2: return edefSCRIPT02;
2095 12 case wScript3: return edefSCRIPT03;
2096 77 case wScript4: return edefSCRIPT04;
2097 case wScript5: return edefSCRIPT05;
2098 case wScript6: return edefSCRIPT06;
2099 case wScript7: return edefSCRIPT07;
2100 case wScript8: return edefSCRIPT08;
2101 case wScript9: return edefSCRIPT09;
2102 993 case wScript10: return edefSCRIPT10;
2103 case wIce: return edefICE;
2104 case wSound: return edefSONIC;
2105 1 case wThrown: return edefTHROWN;
2106 case wRefArrow: return edefREFARROW;
2107 case wRefFire: return edefREFFIRE;
2108 case wRefFire2: return edefREFFIRE2;
2109 //case wPot: return edefPOT;
2110 // case wLitZap: return edefELECTRIC;
2111 // case wZ3Sword: return edefZ3SWORD;
2112 // case wLASWord: return edefLASWORD;
2113 // case wSpinAttk: return edefSPINATTK;
2114 // case wShield: return edefSHIELD;
2115 // case wTrowel: return edefTROWEL;
2116
2117 default: return -1;
2118 }
2119 127255 }
2120
2121 127255 int32_t getDefType(weapon *w)
2122 {
2123 127255 int32_t id = getWeaponID(w);
2124 127255 int32_t edef = weaponToDefence(id);
2125
2/2
✓ Branch 0 taken 123878 times.
✓ Branch 1 taken 3377 times.
127255 if(edef == edefHOOKSHOT)
2126 {
2127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3377 times.
3377 if(w->family_class == itype_switchhook)
2128 return edefSwitchHook;
2129 3377 }
2130 127255 return edef;
2131 127255 }
2132
2133 226722 int32_t getWeaponID(weapon *w)
2134 {
2135 226722 int32_t usewpn = w->useweapon;
2136
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 226492 times.
226722 return (usewpn > 0) ? usewpn : w->id;
2137 }
2138
2139 127255 int32_t enemy::resolveEnemyDefence(weapon *w)
2140 {
2141 //sword edef is 9, but we're reading it at 0
2142 //,
2143 127255 int32_t weapondef = 0;
2144 127255 int32_t wdeftype = getDefType(w);
2145 127255 int32_t usedef = w->usedefense;
2146
2147
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 127255 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
127255 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2148 {
2149 weapondef = usedef*-1;
2150 }
2151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127255 times.
127255 else if(unsigned(wdeftype) < edefLAST255)
2152 {
2153 127255 weapondef = wdeftype;
2154 127255 }
2155 127255 return weapondef;
2156 }
2157
2158 137822 byte get_def_ignrflag(int32_t edef)
2159 {
2160
3/3
✓ Branch 0 taken 114857 times.
✓ Branch 1 taken 3678 times.
✓ Branch 2 taken 19287 times.
137822 switch(edef)
2161 {
2162 case edIGNORE:
2163 case edIGNOREL1:
2164 case edSTUNORIGNORE:
2165 19287 return WPNUNB_IGNR;
2166 case edSTUNORCHINK:
2167 case edCHINK:
2168 case edCHINKL1:
2169 case edCHINKL2:
2170 case edCHINKL4:
2171 case edCHINKL6:
2172 case edCHINKL8:
2173 case edCHINKL10:
2174 case edLEVELCHINK2:
2175 case edLEVELCHINK3:
2176 case edLEVELCHINK4:
2177 case edLEVELCHINK5:
2178 3678 return WPNUNB_BLOCK;
2179 }
2180 114857 return 0;
2181 137822 }
2182
2183 137822 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2184 {
2185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137822 times.
137822 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2186 switch(edef)
2187 {
2188 case edIGNORE:
2189 case edIGNOREL1:
2190 case edCHINK:
2191 case edCHINKL1:
2192 case edCHINKL2:
2193 case edCHINKL4:
2194 case edCHINKL6:
2195 case edCHINKL8:
2196 case edCHINKL10:
2197 case edLEVELCHINK2:
2198 case edLEVELCHINK3:
2199 case edLEVELCHINK4:
2200 case edLEVELCHINK5:
2201 return edNORMAL;
2202 case edSTUNORIGNORE:
2203 case edSTUNORCHINK:
2204 return edSTUNONLY;
2205 }
2206 return edef;
2207 137822 }
2208
2209 // Do we do damage?
2210 // 0: takehit returns 0
2211 // 1: takehit returns 1
2212 // -1: do damage
2213 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2214 126262 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2215 {
2216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126262 times.
126262 if(switch_hooked) return 0;
2217 126262 int32_t tempx = x;
2218 126262 int32_t tempy = y;
2219 126262 int32_t the_defence = 0;
2220
1/2
✓ Branch 0 taken 126262 times.
✗ Branch 1 not taken.
126262 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2221 {
2222 the_defence = edef*-1; //A specific defence type.
2223 }
2224 126262 else the_defence = defense[edef];
2225
2226 126262 the_defence = conv_edef_unblockable(the_defence, unblockable);
2227
2228
3/4
✓ Branch 0 taken 6607 times.
✓ Branch 1 taken 119655 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6607 times.
126262 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2229 {
2230
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6600 times.
✓ Branch 2 taken 7 times.
6607 switch(the_defence)
2231 {
2232 case edIGNORE:
2233 7 return 0;
2234 case edIGNOREL1:
2235 case edSTUNORIGNORE:
2236 if(*power <= 0)
2237 return 0;
2238 }
2239 6600 sfx(WAV_CHINK,pan(int32_t(x)));
2240 6600 return 1;
2241 }
2242
2243 119655 int32_t new_id = id;
2244 119655 int32_t effect_type = dmisc15;
2245 119655 int32_t delay_timer = 90;
2246 119655 enemy *gleeok = NULL;
2247 119655 enemy *ptra = NULL;
2248 119655 int32_t c = 0;
2249
2250
16/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 492 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1931 times.
✓ Branch 6 taken 1862 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 43 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 945 times.
✓ Branch 13 taken 17349 times.
✓ Branch 14 taken 883 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2170 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 158 times.
✓ Branch 26 taken 105 times.
✓ Branch 27 taken 4 times.
✓ Branch 28 taken 93399 times.
119655 switch(the_defence)
2251 {
2252 case edREPLACE:
2253 {
2254 sclk = 0;
2255 if ( dmisc16 > 0 ) new_id = dmisc16;
2256 else new_id = id+1;
2257 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2258 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2259 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2260
2261 //Z_scripterrlog("new id is %d\n", new_id);
2262 switch(guysbuf[new_id&0xFFF].family)
2263 {
2264 //Fixme: possible enemy memory leak. (minor)
2265 case eeWALK:
2266 {
2267 enemy *e = new eStalfos(x,y,new_id,clk);
2268 guys.add(e);
2269 }
2270 break;
2271
2272 case eeLEV:
2273 {
2274 enemy *e = new eLeever(x,y,new_id,clk);
2275 guys.add(e);
2276 }
2277 break;
2278
2279 case eeTEK:
2280 {
2281 enemy *e = new eTektite(x,y,new_id,clk);
2282 guys.add(e);
2283 }
2284 break;
2285
2286 case eePEAHAT:
2287 {
2288 enemy *e = new ePeahat(x,y,new_id,clk);
2289 guys.add(e);
2290 }
2291 break;
2292
2293 case eeZORA:
2294 {
2295 enemy *e = new eZora(x,y,new_id,clk);
2296 guys.add(e);
2297 }
2298 break;
2299
2300 case eeGHINI:
2301 {
2302 enemy *e = new eGhini(x,y,new_id,clk);
2303 guys.add(e);
2304 }
2305 break;
2306
2307 case eeKEESE:
2308 {
2309 enemy *e = new eKeese(x,y,new_id,clk);
2310 guys.add(e);
2311 }
2312 break;
2313
2314 case eeWIZZ:
2315 {
2316 enemy *e = new eWizzrobe(x,y,new_id,clk);
2317 guys.add(e);
2318 }
2319 break;
2320
2321 case eePROJECTILE:
2322 {
2323 enemy *e = new eProjectile(x,y,new_id,clk);
2324 guys.add(e);
2325 }
2326 break;
2327
2328 case eeWALLM:
2329 {
2330 enemy *e = new eWallM(x,y,new_id,clk);
2331 guys.add(e);
2332 }
2333 break;
2334
2335 case eeAQUA:
2336 {
2337 enemy *e = new eAquamentus(x,y,new_id,clk);
2338 guys.add(e);
2339 e->x = x;
2340 e->y = y;
2341 }
2342 break;
2343
2344 case eeMOLD:
2345 {
2346 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0])));
2347 guys.add(e);
2348 e->x = x;
2349 e->y = y;
2350 }
2351 break;
2352
2353 case eeMANHAN:
2354 {
2355 enemy *e = new eManhandla(x,y,new_id,clk);
2356 guys.add(e);
2357 e->x = x;
2358 e->y = y;
2359 }
2360 break;
2361
2362 case eeGLEEOK:
2363 {
2364 *power = 0;
2365 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].attributes[0]);
2366 guys.add(gleeok);
2367 // TODO(crash): check that .add succeeds.
2368 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2369 new_id &= 0xFFF;
2370 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2371 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2372 for(int32_t i=0; i<head_cnt; i++)
2373 {
2374 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2375 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2376 {
2377 al_trace("Gleeok head %d could not be created!\n",i+1);
2378
2379 for(int32_t j=0; j<i+1; j++)
2380 {
2381 guys.del(guys.Count()-1);
2382 }
2383
2384 break;
2385 }
2386 else
2387 {
2388 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2389 }
2390
2391 c-=guysbuf[new_id].attributes[3];
2392 }
2393 return 1;
2394 }
2395
2396 case eeGHOMA:
2397 {
2398 enemy *e = new eGohma(x,y,new_id,clk);
2399 guys.add(e);
2400 e->x = x;
2401 e->y = y;
2402 }
2403 break;
2404
2405 case eeLANM:
2406 {
2407 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])));
2408 guys.add(e);
2409 e->x = x;
2410 e->y = y;
2411 }
2412 break;
2413
2414 case eeGANON:
2415 {
2416 enemy *e = new eGanon(x,y,new_id,clk);
2417 guys.add(e);
2418 e->x = x;
2419 e->y = y;
2420 }
2421 break;
2422
2423 case eeFAIRY:
2424 {
2425 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2426 guys.add(e);
2427 e->x = x;
2428 e->y = y;
2429 }
2430 break;
2431
2432 case eeFIRE:
2433 {
2434 enemy *e = new eFire(x,y,new_id,clk);
2435 guys.add(e);
2436 e->x = x;
2437 e->y = y;
2438 }
2439 break;
2440
2441 case eeOTHER:
2442 {
2443 enemy *e = new eOther(x,y,new_id,clk);
2444 guys.add(e);
2445 e->x = x;
2446 e->y = y;
2447 }
2448 break;
2449
2450 case eeSPINTILE:
2451 {
2452 enemy *e = new eSpinTile(x,y,new_id,clk);
2453 guys.add(e);
2454 e->x = x;
2455 e->y = y;
2456 }
2457 break;
2458
2459 // and these enemies use the misc10/misc2 value
2460 case eeROCK:
2461 {
2462 switch(guysbuf[new_id&0xFFF].attributes[9])
2463 {
2464 case 1:
2465 {
2466 enemy *e = new eBoulder(x,y,new_id,clk);
2467 guys.add(e);
2468 e->x = x;
2469 e->y = y;
2470 }
2471 break;
2472
2473 case 0:
2474 default:
2475 {
2476 enemy *e = new eRock(x,y,new_id,clk);
2477 guys.add(e);
2478 e->x = x;
2479 e->y = y;
2480 }
2481 break;
2482 }
2483
2484 break;
2485 }
2486
2487 case eeTRAP:
2488 {
2489 switch(guysbuf[new_id&0xFFF].attributes[1])
2490 {
2491 case 1:
2492 {
2493 enemy *e = new eTrap2(x,y,new_id,clk);
2494 guys.add(e);
2495 e->x = x;
2496 e->y = y;
2497 }
2498 break;
2499
2500 case 0:
2501 default:
2502 {
2503 enemy *e = new eTrap(x,y,new_id,clk);
2504 guys.add(e);
2505 e->x = x;
2506 e->y = y;
2507 }
2508 break;
2509 }
2510
2511 break;
2512 }
2513
2514 case eeDONGO:
2515 {
2516 switch(guysbuf[new_id&0xFFF].attributes[9])
2517 {
2518 case 1:
2519 {
2520 enemy *e = new eDodongo2(x,y,new_id,clk);
2521 guys.add(e);
2522 e->x = x;
2523 e->y = y;
2524 }
2525 break;
2526
2527 case 0:
2528 default:
2529 {
2530 enemy *e = new eDodongo(x,y,new_id,clk);
2531 guys.add(e);
2532 e->x = x;
2533 e->y = y;
2534 }
2535 break;
2536 }
2537
2538 break;
2539 }
2540
2541 case eeDIG:
2542 {
2543 switch(guysbuf[new_id&0xFFF].attributes[9])
2544 {
2545 case 1:
2546 {
2547 enemy *e = new eLilDig(x,y,new_id,clk);
2548 guys.add(e);
2549 e->x = x;
2550 e->y = y;
2551 }
2552 break;
2553
2554 case 0:
2555 default:
2556 {
2557 enemy *e = new eBigDig(x,y,new_id,clk);
2558 guys.add(e);
2559 e->x = x;
2560 e->y = y;
2561 }
2562 break;
2563 }
2564
2565 break;
2566 }
2567
2568 case eePATRA:
2569 {
2570 switch(guysbuf[new_id&0xFFF].attributes[9])
2571 {
2572 case 1:
2573 {
2574 if (get_qr(qr_HARDCODED_BS_PATRA))
2575 {
2576 enemy *e = new ePatraBS(x,y,new_id,clk);
2577 guys.add(e);
2578 e->x = x;
2579 e->y = y;
2580 break;
2581 }
2582 }
2583 [[fallthrough]];
2584 case 0:
2585 default:
2586 {
2587 enemy *e = new ePatra(x,y,new_id,clk);
2588 guys.add(e);
2589 e->x = x;
2590 e->y = y;
2591 }
2592 break;
2593 }
2594
2595 break;
2596 }
2597
2598 case eeGUY:
2599 {
2600 switch(guysbuf[new_id&0xFFF].attributes[9])
2601 {
2602 case 1:
2603 {
2604 enemy *e = new eTrigger(x,y,new_id,clk);
2605 guys.add(e);
2606 }
2607 break;
2608
2609 case 0:
2610 default:
2611 {
2612 enemy *e = new eNPC(x,y,new_id,clk);
2613 guys.add(e);
2614 }
2615 break;
2616 }
2617
2618 break;
2619 }
2620
2621 case eeSCRIPT01:
2622 case eeSCRIPT02:
2623 case eeSCRIPT03:
2624 case eeSCRIPT04:
2625 case eeSCRIPT05:
2626 case eeSCRIPT06:
2627 case eeSCRIPT07:
2628 case eeSCRIPT08:
2629 case eeSCRIPT09:
2630 case eeSCRIPT10:
2631 case eeSCRIPT11:
2632 case eeSCRIPT12:
2633 case eeSCRIPT13:
2634 case eeSCRIPT14:
2635 case eeSCRIPT15:
2636 case eeSCRIPT16:
2637 case eeSCRIPT17:
2638 case eeSCRIPT18:
2639 case eeSCRIPT19:
2640 case eeSCRIPT20:
2641 {
2642 enemy *e = new eScript(x,y,new_id,clk);
2643 guys.add(e);
2644 e->x = x;
2645 e->y = y;
2646 break;
2647 }
2648
2649
2650 case eeFFRIENDLY01:
2651 case eeFFRIENDLY02:
2652 case eeFFRIENDLY03:
2653 case eeFFRIENDLY04:
2654 case eeFFRIENDLY05:
2655 case eeFFRIENDLY06:
2656 case eeFFRIENDLY07:
2657 case eeFFRIENDLY08:
2658 case eeFFRIENDLY09:
2659 case eeFFRIENDLY10:
2660 {
2661 enemy *e = new eFriendly(x,y,new_id,clk);
2662 guys.add(e);
2663 e->x = x;
2664 e->y = y;
2665 break;
2666 }
2667
2668
2669 default: break;
2670 }
2671
2672 // add segments of segmented enemies
2673 int32_t c=0;
2674
2675 switch(guysbuf[new_id&0xFFF].family)
2676 {
2677 case eeMOLD:
2678 {
2679 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2680 new_id &= 0xFFF;
2681
2682 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].attributes[0])); i++)
2683 {
2684 //christ this is messy -DD
2685 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2686
2687 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2688 {
2689 al_trace("Moldorm segment %d could not be created!\n",i+1);
2690
2691 for(int32_t j=0; j<i+1; j++)
2692 guys.del(guys.Count()-1);
2693
2694 return 0;
2695 }
2696
2697 if(i>0)
2698 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2699
2700
2701 }
2702
2703 break;
2704 }
2705
2706 case eeLANM:
2707 {
2708 new_id &= 0xFFF;
2709 int32_t shft = guysbuf[new_id].attributes[1];
2710 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2711 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2712
2713 if(!guys.add(e))
2714 {
2715 al_trace("Lanmola segment 1 could not be created!\n");
2716 guys.del(guys.Count()-1);
2717 return 0;
2718 }
2719 e->x = x;
2720 e->y = y;
2721
2722
2723
2724 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].attributes[0])); i++)
2725 {
2726 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2727 if(!guys.add(e2))
2728 {
2729 al_trace("Lanmola segment %d could not be created!\n",i+1);
2730
2731 for(int32_t j=0; j<i+1; j++)
2732 guys.del(guys.Count()-1);
2733
2734 return 0;
2735 }
2736 e2->x = x;
2737 e2->y = y;
2738
2739 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2740
2741 }
2742 }
2743 break;
2744
2745 case eeMANHAN:
2746 new_id &= 0xFFF;
2747
2748 for(int32_t i=0; i<((!(guysbuf[new_id].attributes[1]))?4:8); i++)
2749 {
2750 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2751 {
2752 al_trace("Manhandla head %d could not be created!\n",i+1);
2753
2754 for(int32_t j=0; j<i+1; j++)
2755 {
2756 guys.del(guys.Count()-1);
2757 }
2758
2759 return 0;
2760 }
2761
2762
2763 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].attributes[0];
2764 }
2765
2766 break;
2767
2768 case eeGLEEOK:
2769 {
2770 /*
2771 new_id &= 0xFFF;
2772 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].attributes[0]));
2773 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2774 for(int32_t i=0; i<head_cnt; i++)
2775 {
2776 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2777 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2778 {
2779 al_trace("Gleeok head %d could not be created!\n",i+1);
2780
2781 for(int32_t j=0; j<i+1; j++)
2782 {
2783 guys.del(guys.Count()-1);
2784 }
2785
2786 break;
2787 }
2788
2789 c-=guysbuf[new_id].misc4;
2790 */
2791
2792 // }
2793 }
2794 break;
2795
2796
2797 case eePATRA:
2798 {
2799 new_id &= 0xFFF;
2800 int32_t outeyes = 0;
2801 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2802
2803 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[0]); i++)
2804 {
2805 if(!((guysbuf[new_id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2806 {
2807 al_trace("Patra outer eye %d could not be created!\n",i+1);
2808
2809 for(int32_t j=0; j<i+1; j++)
2810 guys.del(guys.Count()-1);
2811
2812 return 0;
2813 }
2814 else
2815 outeyes++;
2816
2817
2818 }
2819
2820 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].attributes[1]); i++)
2821 {
2822 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2823 {
2824 al_trace("Patra inner eye %d could not be created!\n",i+1);
2825
2826 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2827 guys.del(guys.Count()-1);
2828
2829 return 0;
2830 }
2831
2832
2833 }
2834 delete ptra;
2835 break;
2836 }
2837 }
2838
2839
2840 // TODO(crash): check that the above .add succeeded.
2841 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2842 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2843 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2844 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2845 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2846 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2847 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2848 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2849 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2850 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2851 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2852 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2853
2854
2855 item_set = 0; //Do not make a drop.
2856
2857 switch(effect_type)
2858 {
2859 case -7:
2860 {
2861 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2862 Lwpns.add(w);
2863 break;
2864 }
2865 case -6:
2866 {
2867 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2868 Lwpns.add(w);
2869 break;
2870 }
2871 case -5:
2872 {
2873 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2874 Lwpns.add(w);
2875 break;
2876 }
2877 case -4:
2878 {
2879 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2880 Lwpns.add(w);
2881 break;
2882 }
2883 case -3: explode(1); break;
2884 case -2: explode(2); break;
2885 case -1: explode(0); break;
2886 case 0: break;
2887
2888 default:
2889 {
2890 //Dummy weapon function
2891 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2892 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2893 Lwpns.add(w);
2894 break;
2895 }
2896 }
2897
2898
2899 yofs = -32768;
2900 switch(guysbuf[new_id&0xFFF].family)
2901 {
2902 case eeGLEEOK:
2903 {
2904 Z_scripterrlog("Replacing a gleeok.\n");
2905 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2906 hp = -999;
2907 if (tempenemy) tempenemy->hp = -999;
2908 break;
2909
2910 }
2911 default:
2912 hp = -1000; break;
2913 }
2914 int mi = mapind(cur_map, screen_spawned);
2915 ++game->guys[mi];
2916 return 1;
2917
2918 }
2919 case edSPLIT:
2920 {
2921 for ( int32_t q = 0; q < dmisc4; q++ )
2922 {
2923 addenemy(screen_spawned,x,y,
2924 dmisc3+0x1000,-15);
2925
2926 }
2927 item_set = 0; //Do not make a drop.
2928 hp = -1000;
2929 return -1;
2930
2931 }
2932 case edSUMMON:
2933 {
2934 int32_t summon_count = zc::math::SafeMod(zc_oldrand(), dmisc4) + 1;
2935 for ( int32_t q = 0; q < summon_count; q++ )
2936 {
2937 int32_t x2=16*((zc_oldrand()%12)+2);
2938 int32_t y2=16*((zc_oldrand()%7)+2);
2939 addenemy(screen_spawned,
2940 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2941 x2,y2,
2942 dmisc3+0x1000,-15);
2943
2944 }
2945 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2946 return -1;
2947
2948 }
2949
2950 case edEXPLODESMALL:
2951 {
2952 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2953 Ewpns.add(ew);
2954 item_set = 0; //Should we make a drop?
2955 hp = -1000;
2956 return -1;
2957 }
2958
2959
2960 case edEXPLODEHARMLESS:
2961 {
2962 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2963 Ewpns.add(ew);
2964 ew->hyofs = -32768;
2965 item_set = 0; //Should we make a drop?
2966 hp = -1000;
2967 return -1;
2968 }
2969
2970
2971 case edEXPLODELARGE:
2972 {
2973 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2974 Ewpns.add(ew);
2975
2976 hp = -1000;
2977 return -1;
2978 }
2979
2980
2981 case edTRIGGERSECRETS:
2982 {
2983 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
2984 return -1;
2985 }
2986
2987 case edSTUNORCHINK:
2988
2/2
✓ Branch 0 taken 644 times.
✓ Branch 1 taken 1526 times.
2170 if(*power <= 0)
2989 {
2990 644 sfx(WAV_CHINK,pan(int32_t(x)));
2991 644 return 1;
2992 }
2993
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 1119 times.
2645 if (stunclk)
2994 {
2995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_IGNORE))
2996 return 0;
2997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1119 times.
1119 if(get_qr(qr_NO_STUNLOCK_BLOCK))
2998 {
2999 sfx(WAV_CHINK,pan(int32_t(x)));
3000 return 1;
3001 }
3002 1119 }
3003 [[fallthrough]];
3004
3005 case edSTUNORIGNORE:
3006
2/2
✓ Branch 0 taken 955 times.
✓ Branch 1 taken 2502 times.
3457 if(*power <= 0)
3007 955 return 0;
3008
2/2
✓ Branch 0 taken 550 times.
✓ Branch 1 taken 1952 times.
4454 if (stunclk)
3009 {
3010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3011 return 0;
3012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1952 times.
1952 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3013 {
3014 sfx(WAV_CHINK,pan(int32_t(x)));
3015 return 1;
3016 }
3017 1952 }
3018 [[fallthrough]];
3019
3020 case edSTUNONLY:
3021
7/10
✓ Branch 0 taken 4364 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4364 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3817 times.
✓ Branch 7 taken 547 times.
✓ Branch 8 taken 4043 times.
✓ Branch 9 taken 321 times.
4364 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3022 {
3023 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3024 321 return 1;
3025 }
3026
2/2
✓ Branch 0 taken 925 times.
✓ Branch 1 taken 3118 times.
4043 if (stunclk)
3027 {
3028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
3118 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3029 return 0;
3030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3118 times.
3118 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3031 {
3032 sfx(WAV_CHINK,pan(int32_t(x)));
3033 return 1;
3034 }
3035 3118 }
3036 4043 stunclk=160;
3037 4043 sfx(WAV_EHIT,pan(int32_t(x)));
3038 4043 return 1;
3039
3040 case edCHINKL1:
3041 if(*power >= 1*game->get_hero_dmgmult()) break;
3042 [[fallthrough]];
3043 case edCHINKL2:
3044
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 61 times.
113 if(*power >= 2*game->get_hero_dmgmult()) break;
3045 [[fallthrough]];
3046 case edCHINKL4:
3047
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 110 times.
190 if(*power >= 4*game->get_hero_dmgmult()) break;
3048 [[fallthrough]];
3049 case edCHINKL6:
3050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 6*game->get_hero_dmgmult()) break;
3051 [[fallthrough]];
3052 case edCHINKL8:
3053
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 111 times.
154 if(*power >= 8*game->get_hero_dmgmult()) break;
3054 [[fallthrough]];
3055 case edCHINKL10:
3056
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if(*power >= 10*game->get_hero_dmgmult()) break;
3057 [[fallthrough]];
3058 case edCHINK:
3059 1056 sfx(WAV_CHINK,pan(int32_t(x)));
3060 1056 return 1;
3061
3062 case edIGNOREL1:
3063 if(*power > 0) break;
3064 [[fallthrough]];
3065
3066 case edIGNORE:
3067 17349 return 0;
3068
3069 case ed1HKO:
3070 492 *power = hp;
3071 492 return -3;
3072
3073 case ed2x:
3074 {
3075
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3076 //int32_t pow = *power;
3077 //*power = vbound((pow*2),0,214747);
3078 71 return -1;
3079 }
3080 case ed3x:
3081 {
3082 *power = zc_max(1,*power*3);
3083 //int32_t pow = *power;
3084 //*power = vbound((pow*3),0,214747);
3085 return -1;
3086 }
3087
3088 case ed4x:
3089 {
3090 *power = zc_max(1,*power*4);
3091 //int32_t pow = *power;
3092 //*power = vbound((pow*4),0,214747);
3093 return -1;
3094 }
3095
3096
3097 case edHEAL:
3098 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3099 //int32_t pow = *power;
3100 //*power = vbound((pow*-1),0,214747);
3101 //break;
3102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158 times.
158 *power = zc_min(0,*power*-1);
3103 158 return -1;
3104 }
3105 /*
3106 case edLEVELDAMAGE:
3107 {
3108 int32_t pow = *power;
3109 int32_t lvl = *level;
3110 *power = vbound((pow*lvl),0,214747);
3111 break;
3112 }
3113 case edLEVELREDUCTION:
3114 {
3115 int32_t pow = *power;
3116 int32_t lvl = *level;
3117 *power = vbound((pow/lvl),0,214747);
3118 break;
3119 }
3120 */
3121
3122 case edQUARTDAMAGE:
3123
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 3 times.
105 *power = zc_max(1,*power/2);
3124
3125 [[fallthrough]];
3126 case edHALFDAMAGE:
3127
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 156 times.
988 *power = zc_max(1,*power/2);
3128 988 break;
3129
3130 case edSWITCH:
3131 {
3132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(Hero.switchhookclk) return 0; //Already switching!
3133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 switch(family)
3134 {
3135 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3136 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3137 return 0;
3138 }
3139 4 hooked_comborpos = rpos_t::None;
3140 4 hooked_layerbits = 0;
3141 4 switching_object = this;
3142 4 switch_hooked = true;
3143 4 Hero.doSwitchHook(game->get_switchhookstyle());
3144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(QMisc.miscsfx[sfxSWITCHED])
3145 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3146 4 return 1;
3147 }
3148
3149 case 0:
3150 {
3151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93399 times.
93399 if(edef == edefSwitchHook)
3152 return -1;
3153
4/4
✓ Branch 0 taken 19516 times.
✓ Branch 1 taken 73883 times.
✓ Branch 2 taken 7746 times.
✓ Branch 3 taken 11770 times.
93399 if (stunclk && *power == 0)
3154 {
3155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11770 times.
11770 if(get_qr(qr_NO_STUNLOCK_IGNORE))
3156 return 0;
3157
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 11744 times.
11770 if(get_qr(qr_NO_STUNLOCK_BLOCK))
3158 {
3159 26 sfx(WAV_CHINK,pan(int32_t(x)));
3160 26 return 1;
3161 }
3162 11744 }
3163 93373 break;
3164 }
3165 }
3166
3167 94536 return -1;
3168 126262 }
3169
3170 126262 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3171 {
3172
1/2
✓ Branch 0 taken 126262 times.
✗ Branch 1 not taken.
126262 int wuid = w?w->getUID():0;
3173
1/2
✓ Branch 0 taken 126262 times.
✗ Branch 1 not taken.
126262 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3174
3175
1/2
✓ Branch 0 taken 126262 times.
✗ Branch 1 not taken.
126262 if(fakeweap)
3176 Lwpns.add(w);
3177 126262 std::vector<int32_t> &ev = FFCore.eventData;
3178 126262 ev.clear();
3179 126262 ev.push_back(*power*10000);
3180 126262 ev.push_back(edef*10000);
3181 126262 ev.push_back(unblockable*10000);
3182 126262 ev.push_back(wpnId*10000);
3183 126262 ev.push_back(0);
3184 126262 ev.push_back(getUID());
3185 126262 ev.push_back(wuid);
3186
3187 126262 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3188 126262 *power = ev[0]/10000;
3189 126262 edef = ev[1]/10000;
3190 126262 unblockable = byte(ev[2]/10000);
3191 126262 wpnId = ev[3] / 10000;
3192 126262 bool nullify = ev[4]!=0;
3193 126262 ev.clear();
3194 126262 int ret = 0;
3195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126262 times.
126262 if(!nullify)
3196 {
3197 126262 ret = defendNew(wpnId, power, edef, unblockable);
3198
2/2
✓ Branch 0 taken 32349 times.
✓ Branch 1 taken 93913 times.
126262 if(ret < 0)
3199 {
3200 93913 ev.push_back(*power*10000);
3201 93913 ev.push_back(edef*10000);
3202 93913 ev.push_back(unblockable*10000);
3203 93913 ev.push_back(wpnId*10000);
3204 93913 ev.push_back(0);
3205 93913 ev.push_back(getUID());
3206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93913 times.
93913 ev.push_back(w?w->getUID():0);
3207
3208 93913 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3209 93913 *power = ev[0]/10000;
3210 93913 nullify = ev[4]!=0;
3211 93913 ev.clear();
3212 93913 }
3213 126262 }
3214
1/2
✓ Branch 0 taken 126262 times.
✗ Branch 1 not taken.
126262 if(fakeweap)
3215 Lwpns.remove(w);
3216
3217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126262 times.
126262 return nullify ? 0 : ret;
3218 }
3219
3220 99467 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3221 {
3222
2/2
✓ Branch 0 taken 98890 times.
✓ Branch 1 taken 577 times.
99467 if(!realweap) realweap = w;
3223 99467 int32_t wid = getWeaponID(w);
3224
3225 99467 int32_t edef = resolveEnemyDefence(w);
3226
2/2
✓ Branch 0 taken 6269 times.
✓ Branch 1 taken 93198 times.
99467 if(QHeader.zelda_version > 0x250)
3227 6269 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3228
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 92205 times.
✗ Branch 2 not taken.
93198 switch(wid)
3229 {
3230 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3231 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3232 993 return defend(wpnId, power, edefSCRIPT);
3233
3234 case wWhistle:
3235 return -1;
3236
3237 default:
3238 92205 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3239 }
3240 99467 }
3241
3242
3243 // Check defenses without actually acting on them.
3244 27402 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3245 {
3246
4/10
✓ Branch 0 taken 15409 times.
✓ Branch 1 taken 11050 times.
✓ Branch 2 taken 469 times.
✓ Branch 3 taken 474 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
27402 switch(defense[edef])
3247 {
3248 case edSTUNONLY:
3249 474 return false;
3250 case edSTUNORCHINK:
3251 case edCHINK:
3252 15409 return unblockable&WPNUNB_BLOCK;
3253 case edSTUNORIGNORE:
3254 case edIGNORE:
3255 11050 return unblockable&WPNUNB_IGNR;
3256
3257 case edIGNOREL1:
3258 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3259 case edCHINKL1:
3260 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3261
3262 case edCHINKL2:
3263 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3264
3265 case edCHINKL4:
3266 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3267
3268 case edCHINKL6:
3269 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3270
3271 case edCHINKL8:
3272 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3273 }
3274
3275 469 return true;
3276 27402 }
3277
3278 // Do we do damage?
3279 // 0: takehit returns 0
3280 // 1: takehit returns 1
3281 // -1: do damage
3282 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3283 {
3284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3285 {
3286 switch(defense[edef])
3287 {
3288 case edIGNORE:
3289 return 0;
3290 case edIGNOREL1:
3291 case edSTUNORIGNORE:
3292 if(*power <= 0)
3293 return 0;
3294 }
3295
3296 sfx(WAV_CHINK,pan(int32_t(x)));
3297 return 1;
3298 }
3299
3300
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3301 {
3302 case edSTUNORCHINK:
3303 if(*power <= 0)
3304 {
3305 sfx(WAV_CHINK,pan(int32_t(x)));
3306 return 1;
3307 }
3308
3309 [[fallthrough]];
3310 case edSTUNORIGNORE:
3311 if(*power <= 0)
3312 return 0;
3313
3314 [[fallthrough]];
3315 case edSTUNONLY:
3316 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3317 return 1;
3318
3319 stunclk=160;
3320 sfx(WAV_EHIT,pan(int32_t(x)));
3321 return 1;
3322
3323 case edFREEZE:
3324 frozenclock=-1;
3325 //sfx(WAV_FREEZE,pan(int32_t(x)));
3326 return 1;
3327
3328 case edCHINKL1:
3329 if(*power >= 1*game->get_hero_dmgmult()) break;
3330 [[fallthrough]];
3331 case edCHINKL2:
3332 if(*power >= 2*game->get_hero_dmgmult()) break;
3333 [[fallthrough]];
3334 case edCHINKL4:
3335 if(*power >= 4*game->get_hero_dmgmult()) break;
3336 [[fallthrough]];
3337 case edCHINKL6:
3338 if(*power >= 6*game->get_hero_dmgmult()) break;
3339 [[fallthrough]];
3340 case edCHINKL8:
3341 if(*power >= 8*game->get_hero_dmgmult()) break;
3342 [[fallthrough]];
3343 case edCHINKL10:
3344 if(*power >= 10*game->get_hero_dmgmult()) break;
3345 [[fallthrough]];
3346 case edCHINK:
3347 sfx(WAV_CHINK,pan(int32_t(x)));
3348 return 1;
3349 case edTRIGGERSECRETS:
3350 trigger_secrets_for_screen(TriggerSource::Unspecified, screen_spawned, false);
3351 break;
3352
3353 case edIGNOREL1:
3354 if(*power > 0) break;
3355 [[fallthrough]];
3356 case edIGNORE:
3357 800 return 0;
3358
3359 case ed1HKO:
3360 *power = hp;
3361 return -3;
3362
3363 case ed2x:
3364 {
3365 *power = zc_max(1,*power*2);
3366 //int32_t pow = *power;
3367 //*power = vbound((pow*2),0,214747);
3368 return -1;
3369 }
3370 case ed3x:
3371 {
3372 *power = zc_max(1,*power*3);
3373 //int32_t pow = *power;
3374 //*power = vbound((pow*3),0,214747);
3375 return -1;
3376 }
3377
3378 case ed4x:
3379 {
3380 *power = zc_max(1,*power*4);
3381 //int32_t pow = *power;
3382 //*power = vbound((pow*4),0,214747);
3383 return -1;
3384 }
3385
3386
3387 case edHEAL:
3388 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3389 //int32_t pow = *power;
3390 //*power = vbound((pow*-1),0,214747);
3391 //break;
3392 *power = zc_min(0,*power*-1);
3393 return -1;
3394 }
3395 /*
3396 case edLEVELDAMAGE:
3397 {
3398 int32_t pow = *power;
3399 int32_t lvl = *level;
3400 *power = vbound((pow*lvl),0,214747);
3401 break;
3402 }
3403 case edLEVELREDUCTION:
3404 {
3405 int32_t pow = *power;
3406 int32_t lvl = *level;
3407 *power = vbound((pow/lvl),0,214747);
3408 break;
3409 }
3410 */
3411
3412
3413 case edQUARTDAMAGE:
3414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3415
3416 [[fallthrough]];
3417 case edHALFDAMAGE:
3418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3419 7 break;
3420 }
3421
3422 193 return -1;
3423 993 }
3424
3425 // Defend against a particular item class.
3426 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3427 {
3428 int32_t def=-1;
3429
3430 switch(wpnId)
3431 {
3432 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3433 case wBrang:
3434 def = defend(wpnId, power, edefBRANG);
3435 break;
3436
3437 case wHookshot:
3438 def = defend(wpnId, power, edefHOOKSHOT);
3439 break;
3440
3441 // Anyway...
3442 case wBomb:
3443 def = defend(wpnId, power, edefBOMB);
3444 break;
3445
3446 case wSBomb:
3447 def = defend(wpnId, power, edefSBOMB);
3448 break;
3449
3450 case wArrow:
3451 def = defend(wpnId, power, edefARROW);
3452 break;
3453
3454 case wFire:
3455 def = defend(wpnId, power, edefFIRE);
3456 break;
3457
3458 case wWand:
3459 def = defend(wpnId, power, edefWAND);
3460 break;
3461
3462 case wMagic:
3463 def = defend(wpnId, power, edefMAGIC);
3464 break;
3465
3466 case wHammer:
3467 def = defend(wpnId, power, edefHAMMER);
3468 break;
3469
3470 case wSword:
3471 def = defend(wpnId, power, edefSWORD);
3472 break;
3473
3474 case wBeam:
3475 def = defend(wpnId, power, edefBEAM);
3476 break;
3477
3478 case wRefBeam:
3479 def = defend(wpnId, power, edefREFBEAM);
3480 break;
3481
3482 case wRefMagic:
3483 def = defend(wpnId, power, edefREFMAGIC);
3484 break;
3485
3486 case wRefFireball:
3487 def = defend(wpnId, power, edefREFBALL);
3488 break;
3489
3490 case wRefRock:
3491 def = defend(wpnId, power, edefREFROCK);
3492 break;
3493
3494 case wStomp:
3495 def = defend(wpnId, power, edefSTOMP);
3496 break;
3497
3498 case wCByrna:
3499 def = defend(wpnId, power, edefBYRNA);
3500 break;
3501
3502 case wScript1:
3503 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3504 else def = defend(wpnId, power, edefSCRIPT);
3505 break;
3506
3507 case wScript2:
3508 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3509 else def = defend(wpnId, power, edefSCRIPT);
3510 break;
3511
3512 case wScript3:
3513 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3514 else def = defend(wpnId, power, edefSCRIPT);
3515 break;
3516
3517 case wScript4:
3518 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3519 else def = defend(wpnId, power, edefSCRIPT);
3520 break;
3521
3522 case wScript5:
3523 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3524 else def = defend(wpnId, power, edefSCRIPT);
3525 break;
3526
3527 case wScript6:
3528 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3529 else def = defend(wpnId, power, edefSCRIPT);
3530 break;
3531
3532 case wScript7:
3533 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3534 else def = defend(wpnId, power, edefSCRIPT);
3535 break;
3536
3537 case wScript8:
3538 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3539 else def = defend(wpnId, power, edefSCRIPT);
3540 break;
3541
3542 case wScript9:
3543 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3544 else def = defend(wpnId, power, edefSCRIPT);
3545 break;
3546
3547 case wScript10:
3548 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3549 else def = defend(wpnId, power, edefSCRIPT);
3550 break;
3551
3552 case wWhistle:
3553 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3554 else break;
3555 break;
3556
3557 case wRefArrow:
3558 def = defend(wpnId, power, edefREFARROW);
3559 break;
3560 case wRefFire:
3561 def = defend(wpnId, power, edefREFFIRE);
3562 break;
3563 case wRefFire2:
3564 def = defend(wpnId, power, edefREFFIRE2);
3565 break;
3566
3567 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3568 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3569 //of the ten if the quest version is lower than N.
3570 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3571 //such as bool UseSeparatedScriptDefences. hah.
3572 default:
3573 //if(wpnId>=wScript1 && wpnId<=wScript10)
3574 // {
3575 // def = defend(wpnId, power, edefSCRIPT);
3576 // }
3577 // }
3578
3579 break;
3580 }
3581
3582 return def;
3583 }
3584
3585 // take damage or ignore it
3586 // 2 or -2: force wait a frame
3587 // < 0: damage (if any) dealt
3588 // > 0: blocked
3589 // 0: weapon passes through unhindered
3590 265099 int32_t enemy::takehit(weapon *w, weapon* realweap)
3591 {
3592
2/4
✓ Branch 0 taken 265099 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 265099 times.
265099 if(fallclk||drownclk) return 0;
3593
2/2
✓ Branch 0 taken 69674 times.
✓ Branch 1 taken 195425 times.
265099 if(!realweap) realweap = w;
3594 265099 int32_t wpnId = w->id;
3595 265099 int32_t power = w->power;
3596 265099 int32_t wpnx = w->x;
3597 265099 int32_t wpny = w->y;
3598 265099 int32_t enemyHitWeapon = w->parentitem;
3599 int32_t wpnDir;
3600 265099 int32_t parent_item = w->parentitem;
3601
3602
2/2
✓ Branch 0 taken 264984 times.
✓ Branch 1 taken 115 times.
265099 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3603 {
3604 115 wpnId = w->useweapon;
3605 115 }
3606
3607 // If it's a boomerang that just bounced, use the opposite direction;
3608 // otherwise, it might bypass a shield. This probably won't handle
3609 // every case correctly, but it's better than having shields simply
3610 // not work against boomerangs.
3611
8/8
✓ Branch 0 taken 25067 times.
✓ Branch 1 taken 240032 times.
✓ Branch 2 taken 15571 times.
✓ Branch 3 taken 9496 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 3306 times.
✓ Branch 7 taken 11047 times.
265099 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3612 11047 wpnDir = oppositeDir[w->dir];
3613 else
3614 254052 wpnDir = w->dir;
3615
3616
5/8
✓ Branch 0 taken 265099 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 265099 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265099 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8070 times.
✓ Branch 7 taken 272425 times.
265099 if(dying || clk<0 || hclk>0 || superman)
3617 8070 return 0;
3618
3619 //Prevent boomerang from writing to hitby[] for more than one frame.
3620 //This also prevents stunlock.
3621 //if ( stunclk > 0 ) return 0;
3622 //this needs a rule for boomerangs that cannot stunlock!
3623 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3624 //sigh.
3625
3626 272425 int32_t ret = -1;
3627
3628 // This obscure quest rule...
3629
5/6
✓ Branch 0 taken 92385 times.
✓ Branch 1 taken 180040 times.
✓ Branch 2 taken 88881 times.
✓ Branch 3 taken 3504 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 88881 times.
272425 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3630 {
3631 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3632 3504 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3633 3504 wpnDir=zc_oldrand()&3;
3634
3635
4/4
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 3037 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 189 times.
3504 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3636 {
3637 189 wpnDir=down;
3638 189 }
3639
4/4
✓ Branch 0 taken 563 times.
✓ Branch 1 taken 2752 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 285 times.
3315 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3640 {
3641 285 wpnDir=right;
3642 285 }
3643
4/4
✓ Branch 0 taken 2343 times.
✓ Branch 1 taken 687 times.
✓ Branch 2 taken 278 times.
✓ Branch 3 taken 2065 times.
3030 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3644 {
3645 2065 wpnDir=up;
3646 2065 }
3647 else
3648 {
3649 965 wpnDir=left;
3650 }
3651 3504 }
3652
3653 272425 int32_t xdir = dir;
3654 272425 shieldCanBlock=false;
3655
3656
4/4
✓ Branch 0 taken 261145 times.
✓ Branch 1 taken 11280 times.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 258378 times.
273187 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3657
6/6
✓ Branch 0 taken 18354 times.
✓ Branch 1 taken 15587 times.
✓ Branch 2 taken 26211 times.
✓ Branch 3 taken 247754 times.
✓ Branch 4 taken 108 times.
✓ Branch 5 taken 247646 times.
261145 || ((flags&guy_shield_front && wpnDir==(xdir^down)) || (flags&guy_shield_back && wpnDir==(xdir^up)) ||
3658
4/4
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 246627 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 245865 times.
247646 (flags&guy_shield_left && wpnDir==(xdir^(xdir&2?right:left))) || (flags&guy_shield_right && wpnDir==(xdir^(dir&2?left:right)))))
3659 )
3660 // The hammer should already be dealt with by subclasses (Walker etc.)
3661 {
3662
10/10
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 680 times.
✓ Branch 4 taken 5788 times.
✓ Branch 5 taken 338 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 1488 times.
46454 switch(wpnId)
3663 {
3664 // Weapons which shields protect against
3665 case wSword:
3666 case wWand:
3667
2/2
✓ Branch 0 taken 5786 times.
✓ Branch 1 taken 2 times.
5790 if(Hero.getCharging()>0)
3668 2 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3669
3670 [[fallthrough]];
3671 case wHookshot:
3672 case wHSHandle:
3673 case wBrang:
3674 6168 shieldCanBlock=true;
3675 6506 break;
3676
3677 case wBeam:
3678 case wRefBeam:
3679 // Mirror shielded enemies!
3680 #if 0
3681 if(false /*flags&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3682 {
3683 if(wpnId>wEnemyWeapons)
3684 return 0;
3685
3686 sfx(WAV_CHINK,pan(int32_t(x)));
3687 return 1;
3688 }
3689
3690 #endif
3691
3692 [[fallthrough]];
3693 case wRefRock:
3694 case wRefFireball:
3695 case wMagic:
3696 #if 0
3697 if(false /*flags&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3698 {
3699 sfx(WAV_CHINK,pan(int32_t(x)));
3700 return 3;
3701 }
3702
3703 #endif
3704
3705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 368 times.
368 if(wpnId>wEnemyWeapons)
3706 return 0;
3707
3708 [[fallthrough]];
3709 case wArrow:
3710 382 case wRefArrow:
3711 default:
3712 1870 shieldCanBlock=true;
3713 1870 break;
3714
3715 // Bombs
3716 case wSBomb:
3717 case wBomb:
3718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3719 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3720 {
3721 sfx(WAV_CHINK,pan(int32_t(x)));
3722 return 0;
3723 }
3724 else break;
3725
3726 // Weapons which ignore shields
3727 case wWhistle:
3728 case wHammer:
3729 153 break;
3730
3731 // Weapons which shouldn't be removed by shields
3732 case wLitBomb:
3733 case wLitSBomb:
3734 case wWind:
3735 case wPhantom:
3736 case wSSparkle:
3737 case wBait:
3738 864 return 0;
3739
3740 case wFire:
3741 case wRefFire:
3742 case wRefFire2:
3743 ;
3744 680 }
3745 8871 }
3746
3747
8/8
✓ Branch 0 taken 103267 times.
✓ Branch 1 taken 97810 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 270 times.
✓ Branch 4 taken 27402 times.
✓ Branch 5 taken 25021 times.
✓ Branch 6 taken 2767 times.
✓ Branch 7 taken 9056 times.
266016 switch(wpnId)
3748 {
3749 case wWhistle: //No longer completely ignore whistle weapons! -Z
3750 {
3751
3752
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
423 if ( ((itemsbuf[parent_item].flags & item_flag2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3753 {
3754 423 return 0; break;
3755 }
3756 else
3757 {
3758 w->power = power = itemsbuf[parent_item].misc5;
3759
3760 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3761
3762 if(def <= 0)
3763 {
3764 hp -= power;
3765 return def;
3766 }
3767 break;
3768 }
3769 break;
3770 }
3771
3772 case wPhantom:
3773 270 return 0;
3774
3775 case wLitBomb:
3776 case wLitSBomb:
3777 case wBait:
3778 case wWind:
3779 case wSSparkle:
3780 103267 return 0;
3781
3782 case wFSparkle:
3783
3784 // Only take sparkle damage if the sparkle's parent item is not
3785 // defended against.
3786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27402 times.
27402 if(enemyHitWeapon > -1)
3787 {
3788 27402 int32_t p = 0;
3789 27402 int32_t f = itemsbuf[enemyHitWeapon].family;
3790
3791
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27402 times.
27402 switch(f)
3792 {
3793 case itype_arrow:
3794 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3795
3796 break;
3797
3798 case itype_cbyrna:
3799 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3800
3801 break;
3802
3803 case itype_brang:
3804
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 26933 times.
27402 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3805
3806 469 break;
3807
3808 default:
3809 return 0;
3810 }
3811 469 }
3812
3813 469 wpnId = wSword;
3814 469 power = game->get_hero_dmgmult()>>1;
3815 469 goto fsparkle;
3816 break;
3817
3818 case wBrang:
3819 {
3820 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3821 25021 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3822 //preventing stunlock might be best, here. -Z
3823
2/2
✓ Branch 0 taken 5466 times.
✓ Branch 1 taken 19555 times.
25021 if(def >= 0) return def;
3824 19555 ret = def;
3825
3826 // Not hurt by 0-damage weapons
3827
2/2
✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 16371 times.
19555 if(!(flags & guy_bhit))
3828 {
3829 16371 stunclk=160;
3830
3831
3/4
✓ Branch 0 taken 16371 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✓ Branch 3 taken 15060 times.
16371 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3832 {
3833
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3834 1311 goto hitclock;
3835 }
3836
3837 15060 break;
3838 }
3839
3840
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 2793 times.
3184 if(!power)
3841
1/2
✓ Branch 0 taken 2793 times.
✗ Branch 1 not taken.
2793 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3842 else
3843 391 hp-=power;
3844
3845 3184 goto hitclock;
3846 }
3847
3848 case wHookshot:
3849 {
3850 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3851 2767 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3852
3853
2/2
✓ Branch 0 taken 994 times.
✓ Branch 1 taken 1773 times.
2767 if(def >= 0) return def;
3854 1773 ret = def;
3855
3856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1773 times.
1773 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3857
3/4
✓ Branch 0 taken 1773 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625 times.
✓ Branch 3 taken 148 times.
1773 if(swgrab || !(flags & guy_bhit))
3858 {
3859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625 times.
1625 if(!swgrab)
3860 1625 stunclk=160;
3861
3862
3/4
✓ Branch 0 taken 1625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 549 times.
✓ Branch 3 taken 1076 times.
1625 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3863 {
3864
1/2
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
549 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3865 549 goto hitclock;
3866 }
3867
3868 1076 break;
3869 }
3870
3871
3/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
148 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3872 else
3873 45 hp-=power;
3874
3875 148 goto hitclock;
3876 }
3877 break;
3878
3879 case wHSHandle:
3880 {
3881
3/4
✓ Branch 0 taken 9056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✓ Branch 3 taken 8533 times.
9056 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & item_flag1)
3882 523 return 0;
3883
3884
3/4
✓ Branch 0 taken 6093 times.
✓ Branch 1 taken 2440 times.
✓ Branch 2 taken 2440 times.
✗ Branch 3 not taken.
8533 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3885
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2440 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2440 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3886
3887 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3888
6/8
✓ Branch 0 taken 2787 times.
✓ Branch 1 taken 5746 times.
✓ Branch 2 taken 2787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2787 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 502 times.
✓ Branch 7 taken 2285 times.
10245 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3889
6/6
✓ Branch 0 taken 3375 times.
✓ Branch 1 taken 2873 times.
✓ Branch 2 taken 1771 times.
✓ Branch 3 taken 3889 times.
✓ Branch 4 taken 1712 times.
✓ Branch 5 taken 2177 times.
2787 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(guy_shield_back|guy_shield_front|guy_shield_left|guy_shield_right))))
3890 2177 return 0;
3891
3892 12102 power = game->get_hero_dmgmult();
3893 12571 }
3894
3895 fsparkle:
3896
3897 [[fallthrough]];
3898 default:
3899 // Work out the defenses!
3900 {
3901 98889 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3902
3903
2/2
✓ Branch 0 taken 26532 times.
✓ Branch 1 taken 72357 times.
98889 if(def >= 0)
3904 26532 return def;
3905
2/2
✓ Branch 0 taken 71897 times.
✓ Branch 1 taken 460 times.
72357 else if(def == -3) // OHKO... doesn't 'hit' the weapon?
3906 460 ret = 0;
3907 }
3908
3909
2/2
✓ Branch 0 taken 72355 times.
✓ Branch 1 taken 2 times.
144714 if(!power)
3910 {
3911
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3912 2 hp-=1;
3913 else
3914 {
3915 // Don't make a long chain of 'stun' hits
3916 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3917 return 1;
3918
3919
3920 if(!switch_hooked)
3921 stunclk=160;
3922 break;
3923 }
3924 2 }
3925 72355 else hp-=power;
3926
3927 hitclock:
3928 77560 hclk=33;
3929
3930 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3931
2/2
✓ Branch 0 taken 34610 times.
✓ Branch 1 taken 42950 times.
77560 if((dir&2)==(w->dir&2))
3932 {
3933 42950 sclk=(w->dir<<8)+16;
3934 42950 }
3935 77560 }
3936
3937
5/6
✓ Branch 0 taken 74141 times.
✓ Branch 1 taken 19555 times.
✓ Branch 2 taken 21983 times.
✓ Branch 3 taken 71713 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21983 times.
93696 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3938 {
3939 21983 fading=fade_blue_poof;
3940 21983 }
3941
3942
6/6
✓ Branch 0 taken 88407 times.
✓ Branch 1 taken 5289 times.
✓ Branch 2 taken 46937 times.
✓ Branch 3 taken 41470 times.
✓ Branch 4 taken 2347 times.
✓ Branch 5 taken 44590 times.
93696 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3943 {
3944
1/2
✓ Branch 0 taken 7636 times.
✗ Branch 1 not taken.
7636 if( hitsfx > 0 ) //user-set hit sound.
3945 {
3946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7636 times.
7636 if (!dying) //don't play the hit sound on death! -Z
3947 7636 sfx(hitsfx, pan(int32_t(x)));
3948 7636 }
3949 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3950 7636 }
3951 else //2.50.2 or earlier
3952 {
3953 86060 sfx(WAV_EHIT, pan(int32_t(x)));
3954 86060 sfx(hitsfx, pan(int32_t(x)));
3955 }
3956
2/2
✓ Branch 0 taken 93667 times.
✓ Branch 1 taken 29 times.
93696 if(family==eeGUY)
3957 29 sfx(WAV_EDEAD, pan(int32_t(x)));
3958
3959 // Penetrating weapons
3960
4/4
✓ Branch 0 taken 91822 times.
✓ Branch 1 taken 1874 times.
✓ Branch 2 taken 85009 times.
✓ Branch 3 taken 8687 times.
93696 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3961 {
3962 8687 int32_t item=enemyHitWeapon;
3963
3964
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 7075 times.
8687 if(wpnId==wArrow)
3965 {
3966 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3967
5/6
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 379 times.
✓ Branch 3 taken 1105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 379 times.
1612 if(item>=0 && (itemsbuf[item].flags&item_flag1) && (itemsbuf[parent_item].family == itype_arrow))
3968 379 return 0;
3969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1233 times.
1233 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3970 //if(item<0)
3971 else
3972 1233 item=current_item_id(itype_arrow);
3973 1233 }
3974
3975 else
3976 {
3977
3978 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3979
3/6
✓ Branch 0 taken 7057 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7057 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7075 if(item>=0 && (itemsbuf[item].flags&item_flag3) && (itemsbuf[parent_item].family == itype_sword))
3980 return 0;
3981
3982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7075 times.
7075 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3983 else
3984 //if(item<0)
3985 7075 item=current_item_id(itype_sword);
3986 }
3987 8308 }
3988
3989 93317 return ret;
3990 269215 }
3991
3992 61725286 bool enemy::dont_draw()
3993 {
3994
6/6
✓ Branch 0 taken 61260773 times.
✓ Branch 1 taken 464513 times.
✓ Branch 2 taken 61189866 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 175008 times.
✓ Branch 5 taken 61085765 times.
61725286 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
3995 639521 return true;
3996
3997
2/2
✓ Branch 0 taken 1371825 times.
✓ Branch 1 taken 59713940 times.
61085765 if(flags&guy_invisible)
3998 1371825 return true;
3999
4000
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 59713508 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
59713940 if(flags&guy_lens_only && !lensclk)
4001 return true;
4002
4003 59713940 return false;
4004 61725286 }
4005
4006 #define DRAW_NORMAL 2
4007 #define DRAW_CLOAKED 1
4008 #define DRAW_INVIS 0
4009 // base drawing function to be used by all derived classes instead of
4010 // sprite::draw()
4011 44798875 void enemy::draw(BITMAP *dest)
4012 {
4013 44798875 didScriptThisFrame = false; //Since there's no better place to put it
4014
6/6
✓ Branch 0 taken 44041194 times.
✓ Branch 1 taken 757681 times.
✓ Branch 2 taken 43958544 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 317531 times.
✓ Branch 5 taken 43723663 times.
44798875 if(fading==fade_invisible || (((flags&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4015 1075212 return;
4016
2/2
✓ Branch 0 taken 2767665 times.
✓ Branch 1 taken 40955998 times.
43723663 if(flags&guy_invisible)
4017 2767665 return;
4018
4019 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4020 // be cloaked if they have "invisible displays as cloaked" checked.
4021
4022 40955998 byte canSee = DRAW_NORMAL;
4023 //Enemy specific stuff
4024
2/2
✓ Branch 0 taken 40954834 times.
✓ Branch 1 taken 1164 times.
40955998 if ( editorflags & ENEMY_FLAG1 )
4025 {
4026 1164 canSee = DRAW_INVIS;
4027
1/2
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
1164 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4028
2/4
✓ Branch 0 taken 1164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
1164 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4029 {
4030 if (game->item[dmisc13])
4031 {
4032 canSee = DRAW_NORMAL;
4033 }
4034 //else if ( lensclk && getlensid.flags SHOWINVIS )
4035 //{
4036 //
4037 //}
4038 //else
4039 //{
4040 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4041 // //otherwisem invisible
4042 //}
4043 }
4044 1164 }
4045 //Room specific
4046 40955998 mapscr* scr = get_scr(screen_spawned);
4047
2/2
✓ Branch 0 taken 38784799 times.
✓ Branch 1 taken 2171199 times.
40955998 if (scr->flags3&fINVISROOM)
4048 {
4049
4/6
✓ Branch 0 taken 2171199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226004 times.
✓ Branch 3 taken 1945195 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 226004 times.
2397203 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226004 times.
226004 !((itemsbuf[Hero.getLastLensID()].flags & item_flag5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4051 2171199 }
4052 //Lens check
4053
2/2
✓ Branch 0 taken 27537 times.
✓ Branch 1 taken 40928461 times.
40955998 if (lensclk)
4054 {
4055
2/2
✓ Branch 0 taken 27105 times.
✓ Branch 1 taken 432 times.
27537 if(flags&guy_lens_only)
4056 {
4057
1/2
✓ Branch 0 taken 432 times.
✗ Branch 1 not taken.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4058 432 }
4059 27537 }
4060 else
4061 {
4062
2/2
✓ Branch 0 taken 40855045 times.
✓ Branch 1 taken 73416 times.
40928461 if(flags&guy_lens_only)
4063 73416 canSee = DRAW_INVIS;
4064 }
4065
3/4
✓ Branch 0 taken 74580 times.
✓ Branch 1 taken 40881418 times.
✓ Branch 2 taken 74580 times.
✗ Branch 3 not taken.
40955998 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4066
3/4
✓ Branch 0 taken 40655414 times.
✓ Branch 1 taken 300584 times.
✓ Branch 2 taken 40655414 times.
✗ Branch 3 not taken.
40955998 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4067
4068
2/2
✓ Branch 0 taken 40881418 times.
✓ Branch 1 taken 74580 times.
40955998 if (canSee == DRAW_INVIS)
4069 74580 return;
4070
4071
4/4
✓ Branch 0 taken 40879043 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40879036 times.
40881418 if(fallclk||drownclk)
4072 {
4073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 if (canSee == DRAW_CLOAKED)
4074 {
4075 sprite::drawcloaked(dest);
4076 }
4077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2382 times.
2382 else if (canSee == DRAW_NORMAL)
4078 {
4079 2382 sprite::draw(dest);
4080 2382 }
4081 2382 return;
4082 }
4083 40879036 int32_t cshold=cs;
4084
4085
2/2
✓ Branch 0 taken 903232 times.
✓ Branch 1 taken 39975804 times.
40879036 if(dying)
4086 {
4087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 903232 times.
903232 if(clk2>=19)
4088 {
4089 if(!(clk2&2))
4090 {
4091 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4092 if (canSee == DRAW_CLOAKED)
4093 {
4094 sprite::drawcloaked(dest);
4095 }
4096 else if (canSee == DRAW_NORMAL)
4097 {
4098 sprite::draw(dest);
4099 }
4100 }
4101 return;
4102 }
4103
4104 903232 flip = 0;
4105 903232 tile = wpnsbuf[spr_death].tile;
4106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 903232 times.
903232 if ( do_animation )
4107 {
4108 903232 int32_t offs = 0;
4109
2/2
✓ Branch 0 taken 852067 times.
✓ Branch 1 taken 51165 times.
903232 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4110 {
4111
2/2
✓ Branch 0 taken 49536 times.
✓ Branch 1 taken 1629 times.
51165 if(clk2 > 2)
4112 {
4113 1629 spr_death_anim_clk=0;
4114 1629 clk2=1;
4115
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1615 times.
1629 if(hp > -1000)
4116 1615 death_sfx();
4117 1629 }
4118
4/4
✓ Branch 0 taken 38466 times.
✓ Branch 1 taken 12699 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 38064 times.
51165 if(clk2==1 && spr_death_anim_clk>-1)
4119 {
4120 38064 ++clk2;
4121
2/2
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35682 times.
38064 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4122
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 38043 times.
38064 spr_death_anim_frm *= zc_max(1,txsz);
4123 38064 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4124
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 37988 times.
38064 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4125
6/6
✓ Branch 0 taken 2382 times.
✓ Branch 1 taken 35682 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 38062 times.
✓ Branch 4 taken 36453 times.
✓ Branch 5 taken 1611 times.
38064 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4126 {
4127 1611 spr_death_anim_clk=-1;
4128 1611 clk2=1;
4129 1611 }
4130 38064 }
4131 51165 tile += spr_death_anim_frm;
4132 51165 }
4133
2/2
✓ Branch 0 taken 315607 times.
✓ Branch 1 taken 536460 times.
852067 else if(BSZ)
4134 {
4135
2/2
✓ Branch 0 taken 248172 times.
✓ Branch 1 taken 67435 times.
315607 offs = zc_min((15-clk2)/3,4);
4136 315607 }
4137
4/4
✓ Branch 0 taken 357718 times.
✓ Branch 1 taken 178742 times.
✓ Branch 2 taken 178730 times.
✓ Branch 3 taken 178988 times.
536460 else if(clk2>6 && clk2<=12)
4138 {
4139 178988 offs = 1;
4140 178988 }
4141
4142
2/2
✓ Branch 0 taken 455087 times.
✓ Branch 1 taken 448145 times.
903232 if(offs)
4143 {
4144
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 447695 times.
448145 offs *= zc_max(1,txsz);
4145 448145 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4146
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 447707 times.
448145 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4147 448145 }
4148 903232 tile += offs;
4149 903232 }
4150
4151
6/6
✓ Branch 0 taken 852067 times.
✓ Branch 1 taken 51165 times.
✓ Branch 2 taken 536460 times.
✓ Branch 3 taken 315607 times.
✓ Branch 4 taken 189182 times.
✓ Branch 5 taken 347278 times.
903232 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4152 555954 cs = wpnsbuf[spr_death].csets&15;
4153 else
4154 347278 cs = (((clk2+5)>>1)&3)+6;
4155 903232 }
4156
3/4
✓ Branch 0 taken 1197022 times.
✓ Branch 1 taken 38778782 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1197022 times.
39975804 else if(hclk>0 && getCanFlicker())
4157 {
4158 1197022 cs = getFlashingCSet();
4159 1197022 }
4160 //draw every other frame for flickering enemies
4161
2/2
✓ Branch 0 taken 248031 times.
✓ Branch 1 taken 40631005 times.
40879036 if (is_hitflickerframe(false))
4162 {
4163
5/6
✓ Branch 0 taken 90246 times.
✓ Branch 1 taken 157785 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 90245 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 157786 times.
248031 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4164
2/4
✓ Branch 0 taken 248031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248031 times.
248031 if (game->get_spriteflickercolor() || temp_flicker_color)
4165 {
4166 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4167 sprite_flicker_color = temp_flicker_color;
4168 sprite::draw(dest);
4169 }
4170 248031 }
4171 else
4172 {
4173
2/2
✓ Branch 0 taken 225162 times.
✓ Branch 1 taken 40405843 times.
40631005 if (canSee == DRAW_CLOAKED)
4174 {
4175 225162 sprite::drawcloaked(dest);
4176 225162 }
4177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40405843 times.
40405843 else if (canSee == DRAW_NORMAL)
4178 {
4179
1/2
✓ Branch 0 taken 40405843 times.
✗ Branch 1 not taken.
40405843 if ( frozenclock < 0 )
4180 {
4181 if ( frozentile > 0 ) tile = frozentile;
4182 loadpalset(csBOSS,frozencset);
4183 }
4184 40405843 sprite::draw(dest);
4185 40405843 }
4186 }
4187 40879036 cs=cshold;
4188 44798875 }
4189
4190 //old zc bosses
4191 40776895 void enemy::drawzcboss(BITMAP *dest)
4192 {
4193 40776895 didScriptThisFrame = false; //Since there's no better place to put it
4194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40776895 times.
40776895 if(dont_draw())
4195 return;
4196
4197 40776895 int32_t cshold=cs;
4198
4199
2/2
✓ Branch 0 taken 782993 times.
✓ Branch 1 taken 39993902 times.
40776895 if(dying)
4200 {
4201
2/2
✓ Branch 0 taken 3960 times.
✓ Branch 1 taken 779033 times.
782993 if(clk2>=19)
4202 {
4203
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 1980 times.
3960 if(!(clk2&2))
4204 1980 sprite::drawzcboss(dest);
4205
4206 3960 return;
4207 }
4208
4209 779033 flip = 0;
4210 779033 tile = wpnsbuf[spr_death].tile;
4211
4212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779033 times.
779033 if ( do_animation )
4213 {
4214
2/2
✓ Branch 0 taken 774517 times.
✓ Branch 1 taken 4516 times.
779033 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4215 {
4216
2/2
✓ Branch 0 taken 4510 times.
✓ Branch 1 taken 6 times.
4516 if(clk2 > 2)
4217 {
4218 6 spr_death_anim_clk=0;
4219 6 clk2=1;
4220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(hp > -1000)
4221 6 death_sfx();
4222 6 }
4223
4/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 76 times.
4516 if(clk2==1 && spr_death_anim_clk>-1)
4224 {
4225 76 ++clk2;
4226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm *= zc_max(1,txsz);
4228 76 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4230
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 74 times.
✓ Branch 5 taken 2 times.
76 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4231 {
4232 2 spr_death_anim_clk=-1;
4233 2 clk2=1;
4234 2 }
4235 76 }
4236 4516 tile += spr_death_anim_frm;
4237 4516 }
4238
2/2
✓ Branch 0 taken 278586 times.
✓ Branch 1 taken 495931 times.
774517 else if(BSZ)
4239
2/2
✓ Branch 0 taken 219134 times.
✓ Branch 1 taken 59452 times.
278586 tile += zc_min((15-clk2)/3,4);
4240
4/4
✓ Branch 0 taken 330584 times.
✓ Branch 1 taken 165347 times.
✓ Branch 2 taken 165189 times.
✓ Branch 3 taken 165395 times.
495931 else if(clk2>6 && clk2<=12)
4241 165395 ++tile;
4242 779033 }
4243
4244
6/6
✓ Branch 0 taken 774517 times.
✓ Branch 1 taken 4516 times.
✓ Branch 2 taken 495931 times.
✓ Branch 3 taken 278586 times.
✓ Branch 4 taken 183872 times.
✓ Branch 5 taken 312059 times.
779033 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4245 466974 cs = wpnsbuf[spr_death].csets&15;
4246 else
4247 312059 cs = (((clk2+5)>>1)&3)+6;
4248 779033 }
4249
2/2
✓ Branch 0 taken 38786353 times.
✓ Branch 1 taken 1207549 times.
39993902 else if(hclk>0)
4250 {
4251 1207549 cs = getFlashingCSet();
4252 1207549 }
4253
4254 40772935 mapscr* scr = get_scr(screen_spawned);
4255
4256
3/4
✓ Branch 0 taken 2045619 times.
✓ Branch 1 taken 38727316 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7543 times.
40780478 if((scr->flags3&fINVISROOM) &&
4257
2/2
✓ Branch 0 taken 7543 times.
✓ Branch 1 taken 2038076 times.
2045619 !(current_item(itype_amulet)) &&
4258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7543 times.
7543 !(get_qr(qr_LENSSEESENEMIES) &&
4259 7543 lensclk) && family!=eeGANON)
4260 {
4261 7543 sprite::drawcloaked(dest);
4262 7543 }
4263 else
4264 {
4265
2/2
✓ Branch 0 taken 23473 times.
✓ Branch 1 taken 40741919 times.
40765392 if (is_hitflickerframe(true))
4266 {
4267
4/6
✓ Branch 0 taken 885 times.
✓ Branch 1 taken 22588 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 885 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 22588 times.
23473 int32_t temp_flicker_color = (hp > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
4268
1/2
✓ Branch 0 taken 23473 times.
✗ Branch 1 not taken.
23473 if (game->get_spriteflickercolor())
4269 {
4270 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
4271 sprite_flicker_color = temp_flicker_color;
4272 sprite::drawzcboss(dest);
4273 }
4274 23473 }
4275 else
4276 40741919 sprite::drawzcboss(dest);
4277 }
4278
4279 40772935 cs=cshold;
4280 40776895 }
4281
4282
4283 // similar to the overblock function--can do up to a 32x32 sprite
4284 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4285 323101 void enemy::drawblock(BITMAP *dest,int32_t mask)
4286 {
4287 323101 int32_t thold=tile;
4288 323101 int32_t t1=tile;
4289 323101 int32_t t2=tile+20;
4290 323101 int32_t t3=tile+1;
4291 323101 int32_t t4=tile+21;
4292
4293
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 323101 times.
323101 switch(mask)
4294 {
4295 case 1:
4296 enemy::drawzcboss(dest);
4297 break;
4298
4299 case 3:
4300 if(flip&2)
4301 zc_swap(t1,t2);
4302
4303 tile=t1;
4304 enemy::drawzcboss(dest);
4305 tile=t2;
4306 yofs+=16;
4307 enemy::drawzcboss(dest);
4308 yofs-=16;
4309 break;
4310
4311 case 5:
4312 t2=tile+1;
4313
4314 if(flip&1)
4315 zc_swap(t1,t2);
4316
4317 tile=t1;
4318 enemy::drawzcboss(dest);
4319 tile=t2;
4320 xofs+=16;
4321 enemy::drawzcboss(dest);
4322 xofs-=16;
4323 break;
4324
4325 case 15:
4326
2/2
✓ Branch 0 taken 316412 times.
✓ Branch 1 taken 6689 times.
323101 if(flip&1)
4327 {
4328 6689 zc_swap(t1,t3);
4329 6689 zc_swap(t2,t4);
4330 6689 }
4331
4332
1/2
✓ Branch 0 taken 323101 times.
✗ Branch 1 not taken.
323101 if(flip&2)
4333 {
4334 zc_swap(t1,t2);
4335 zc_swap(t3,t4);
4336 }
4337
4338 323101 tile=t1;
4339 323101 enemy::drawzcboss(dest);
4340 323101 tile=t2;
4341 323101 yofs+=16;
4342 323101 enemy::drawzcboss(dest);
4343 323101 yofs-=16;
4344 323101 tile=t3;
4345 323101 xofs+=16;
4346 323101 enemy::drawzcboss(dest);
4347 323101 tile=t4;
4348 323101 yofs+=16;
4349 323101 enemy::drawzcboss(dest);
4350 323101 xofs-=16;
4351 323101 yofs-=16;
4352 323101 break;
4353 }
4354
4355 323101 tile=thold;
4356 323101 }
4357
4358 20384566 void enemy::drawshadow(BITMAP *dest, bool translucent)
4359 {
4360
4/4
✓ Branch 0 taken 18373220 times.
✓ Branch 1 taken 2011346 times.
✓ Branch 2 taken 526918 times.
✓ Branch 3 taken 17846302 times.
20384566 if(dont_draw() || isSideViewGravity())
4361 {
4362 2538264 return;
4363 }
4364
4365
2/2
✓ Branch 0 taken 327648 times.
✓ Branch 1 taken 17518654 times.
17846302 if(dying)
4366 {
4367 327648 return;
4368 }
4369
4370 17518654 mapscr* scr = get_scr(screen_spawned);
4371
4/4
✓ Branch 0 taken 1718249 times.
✓ Branch 1 taken 15800405 times.
✓ Branch 2 taken 347010 times.
✓ Branch 3 taken 17171644 times.
17518654 if(((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4372 17518654 (darkroom))
4373 {
4374 347010 return;
4375 }
4376 else
4377 {
4378
4/4
✓ Branch 0 taken 16572489 times.
✓ Branch 1 taken 599155 times.
✓ Branch 2 taken 16525018 times.
✓ Branch 3 taken 47471 times.
17171644 if(enemycanfall(id, false) && shadowtile == 0)
4379 47471 shadowtile = wpnsbuf[spr_shadow].tile;
4380
4381
5/6
✓ Branch 0 taken 16227762 times.
✓ Branch 1 taken 943882 times.
✓ Branch 2 taken 16227762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15628607 times.
✓ Branch 5 taken 599155 times.
17171644 if(z>0 || fakez>0 || !enemycanfall(id, false))
4382 {
4383
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1542762 times.
1543037 if(!shadow_overpit(this))
4384 1542762 sprite::drawshadow(dest,translucent);
4385 1543037 }
4386 }
4387 20384566 }
4388
4389 126838 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4390 {
4391 126838 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4392
4393
1/2
✓ Branch 0 taken 126838 times.
✗ Branch 1 not taken.
126838 if(sub!=NULL)
4394 {
4395 126838 xofs-=mx;
4396 126838 yofs-=my;
4397 126838 enemy::draw(sub);
4398 126838 xofs+=mx;
4399 126838 yofs+=my;
4400 126838 destroy_bitmap(sub);
4401 126838 }
4402 else
4403 enemy::draw(dest);
4404 126838 }
4405
4406 9 void enemy::init_size_flags()
4407 {
4408
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; }
4409
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
9 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
4410
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
4411
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
4412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
4413
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
4414
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
4415
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
4416
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
4417 {
4418 yofs = (int32_t)d->yofs;
4419 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset);
4420 }
4421
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
4422 9 }
4423
4424 // override hit detection to check for invicibility, stunned, etc
4425 112256508 bool enemy::hit()
4426 {
4427
4/4
✓ Branch 0 taken 110930329 times.
✓ Branch 1 taken 1326179 times.
✓ Branch 2 taken 109121370 times.
✓ Branch 3 taken 1808959 times.
112256508 if(dying || hclk>0) return false;
4428 109121370 return sprite::hit();
4429 112256508 }
4430 730351 bool enemy::hit(sprite *s)
4431 {
4432
3/4
✓ Branch 0 taken 730351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 713374 times.
✓ Branch 3 taken 16977 times.
730351 if(!hit() || !s->hit()) return false;
4433 713374 return sprite::hit(s);
4434 730351 }
4435
4436 44557109 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4437 {
4438
2/2
✓ Branch 0 taken 3964188 times.
✓ Branch 1 taken 40592921 times.
44557109 if(!hit()) return false;
4439 40592921 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4440 44557109 }
4441 78013 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4442 {
4443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78013 times.
78013 if(!hit()) return false;
4444 78013 return sprite::hit(tx,ty,txsz2,tysz2);
4445 78013 }
4446
4447 11162293 bool enemy::hit(weapon *w)
4448 {
4449
2/2
✓ Branch 0 taken 1195690 times.
✓ Branch 1 taken 9966603 times.
11162293 if(!hit()) return false;
4450
4451
2/2
✓ Branch 0 taken 6647382 times.
✓ Branch 1 taken 3319221 times.
9966603 if (replay_version_check(0, 14))
4452 {
4453
4/6
✓ Branch 0 taken 6422331 times.
✓ Branch 1 taken 225051 times.
✓ Branch 2 taken 6422331 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6422331 times.
✗ Branch 5 not taken.
6647382 if(!w->scriptcoldet || w->fallclk || w->drownclk)
4454 225051 return false;
4455 6422331 return sprite::hit(w);
4456 }
4457 3319221 return w->hit(this);
4458 11162293 }
4459
4460 9489971 bool enemy::can_pitfall(bool checkspawning)
4461 {
4462
4/4
✓ Branch 0 taken 9470038 times.
✓ Branch 1 taken 19933 times.
✓ Branch 2 taken 9459293 times.
✓ Branch 3 taken 30678 times.
9489971 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4463
2/2
✓ Branch 0 taken 9441624 times.
✓ Branch 1 taken 17669 times.
9459293 switch(guysbuf[id&0xFFF].family)
4464 {
4465 case eeAQUA:
4466 case eeDIG:
4467 case eeDONGO:
4468 case eeFAIRY:
4469 case eeGANON:
4470 case eeGHOMA:
4471 case eeGLEEOK:
4472 case eeGUY:
4473 case eeLANM:
4474 case eeMANHAN:
4475 case eeMOLD:
4476 case eeNONE:
4477 case eePATRA:
4478 case eeZORA:
4479 17669 return false; //Disallowed types
4480 default:
4481 9441624 return true;
4482 }
4483 9489971 }
4484 //Handle death
4485 37848173 void enemy::try_death(bool force_kill)
4486 {
4487
8/8
✓ Branch 0 taken 37791604 times.
✓ Branch 1 taken 56569 times.
✓ Branch 2 taken 37791593 times.
✓ Branch 3 taken 11 times.
✓ Branch 4 taken 43605 times.
✓ Branch 5 taken 37747988 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 43604 times.
37848173 if(!dying && (force_kill || (hp<=0 && !immortal)))
4488 {
4489 43615 std::vector<int32_t> &ev = FFCore.eventData;
4490 43615 ev.clear();
4491 43615 ev.push_back(10000);
4492 43615 ev.push_back(getUID());
4493
4494 43615 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4495 43615 bool isSaved = !ev[0];
4496 43615 ev.clear();
4497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43615 times.
43615 if(isSaved) return;
4498
4499
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 43565 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 44 times.
43615 if (itemguy && get_screen_state(screen_spawned).item_state == ScreenItemState::CarriedByEnemy)
4500 {
4501
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 44 times.
95 for(int32_t i=0; i<items.Count(); i++)
4502 {
4503
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 44 times.
51 if(((item*)items.spr(i))->pickup&ipENEMY && screen_spawned == ((item*)items.spr(i))->screen_spawned)
4504 {
4505
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 3 times.
44 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4506 {
4507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4508 {
4509 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4510 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4511 }
4512 else
4513 {
4514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(extend >= 3)
4515 {
4516 items.spr(i)->x = x+(txsz-1)*8;
4517 items.spr(i)->y = y-2+(tysz-1)*8;
4518 }
4519 else
4520 {
4521 3 items.spr(i)->x = x;
4522 3 items.spr(i)->y = y - 2;
4523 }
4524 }
4525 3 items.spr(i)->z = z;
4526 3 items.spr(i)->fakez = fakez;
4527 3 }
4528 else
4529 {
4530 41 items.spr(i)->x = x;
4531 41 items.spr(i)->y = y - 2;
4532 }
4533 44 }
4534 51 }
4535 44 }
4536
4537 43615 dying=true;
4538
4539
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 43583 times.
43615 if(fading==fade_flash_die)
4540 32 clk2=19+18*4;
4541 else
4542 {
4543 43583 clk2 = BSZ ? 15 : 19;
4544
4545
2/2
✓ Branch 0 taken 21063 times.
✓ Branch 1 taken 22520 times.
43583 if(fading!=fade_blue_poof)
4546 22520 fading=0;
4547 }
4548
4549
2/2
✓ Branch 0 taken 43565 times.
✓ Branch 1 taken 50 times.
43615 if(itemguy)
4550 {
4551 50 screen_item_set_state(screen_spawned, ScreenItemState::None);
4552 50 item_set=0;
4553 50 }
4554
6/6
✓ Branch 0 taken 42561 times.
✓ Branch 1 taken 1054 times.
✓ Branch 2 taken 33894 times.
✓ Branch 3 taken 8667 times.
✓ Branch 4 taken 1428 times.
✓ Branch 5 taken 32466 times.
43615 if (screen_spawned < 128 && count_enemy && !script_spawned)
4555 32466 game->guys[mapind(cur_map, screen_spawned)] -= 1;
4556 43615 }
4557 37848173 }
4558
4559 // --==**==--
4560
4561 // Movement routines that can be used by derived classes as needed
4562
4563 // --==**==--
4564
4565 554693 void enemy::fix_coords(bool bound)
4566 {
4567
1/2
✓ Branch 0 taken 554693 times.
✗ Branch 1 not taken.
554693 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4568
1/2
✓ Branch 0 taken 554693 times.
✗ Branch 1 not taken.
554693 if(moveflags & move_ignore_screenedge) bound = false;
4569
4570
2/2
✓ Branch 0 taken 81680 times.
✓ Branch 1 taken 473013 times.
554693 if(bound)
4571 {
4572 473013 int w = world_w;
4573 473013 int h = world_h;
4574
4575
1/2
✓ Branch 0 taken 473013 times.
✗ Branch 1 not taken.
473013 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4576 {
4577
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 473011 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
473013 x=vbound(x, 0, (( guysbuf[id].SIZEflags&OVERRIDE_TILE_WIDTH && !isflier(id) ) ? (w-((txsz-1)*16)) : w-16));
4578
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 473011 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
473013 y=vbound(y, 0,(( guysbuf[id].SIZEflags&OVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (h-((txsz-1)*16)) : h-16));
4579 473013 }
4580 else
4581 {
4582 x=vbound(x, 0, w-16);
4583 y=vbound(y, 0, h-16);
4584 }
4585 473013 }
4586
4587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 554693 times.
554693 if(!OUTOFBOUNDS(id, x, y))
4588 {
4589 554693 do_fix(x, 16, true);
4590
2/2
✓ Branch 0 taken 1139 times.
✓ Branch 1 taken 553554 times.
554693 if(isSideViewGravity())
4591 1139 do_fix(y,8,true);
4592 553554 else do_fix(y,16,true);
4593 554693 }
4594 554693 }
4595 9077 bool enemy::cannotpenetrate()
4596 {
4597
4/4
✓ Branch 0 taken 8902 times.
✓ Branch 1 taken 175 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8864 times.
9077 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4598 }
4599
4600 562 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4601 {
4602 bool ok;
4603 562 int32_t dx = 0, dy = 0;
4604 562 int32_t sv = 8;
4605
4606 //Why is this here??? Why is it needed???
4607 562 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4608
4609
8/9
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 78 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 81 times.
✗ Branch 8 not taken.
562 switch(ndir)
4610 {
4611 case 8:
4612 case up:
4613
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
69 if(canfall(id) && isSideViewGravity())
4614 return false;
4615
4616 69 dy = dy1-s;
4617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 special = (special==spw_clipbottomright)?spw_none:special;
4618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4619 69 break;
4620
4621 case 12:
4622 case down:
4623
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
51 if(canfall(id) && isSideViewGravity())
4624 return false;
4625
4626 51 dy = dy2+s;
4627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4628 51 break;
4629
4630 case 14:
4631 case left:
4632 47 dx = dx1-s;
4633 47 sv = ((isSideViewGravity())?7:8);
4634
2/4
✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 47 times.
47 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4635
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 45 times.
47 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4636 47 break;
4637
4638 case 10:
4639 case right:
4640 85 dx = dx2+s;
4641 85 sv = ((isSideViewGravity())?7:8);
4642
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 79 times.
85 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4643 85 break;
4644
4645 case 9:
4646 case r_up:
4647 94 dx = dx2+s;
4648 94 dy = dy1-s;
4649
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 1 times.
187 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4651 94 break;
4652
4653 case 11:
4654 case r_down:
4655 78 dx = dx2+s;
4656 78 dx = dy2+s;
4657
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 1 times.
155 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4659 78 break;
4660
4661 case 13:
4662 case l_down:
4663 57 dx = dx1-s;
4664 57 dy = dy2+s;
4665
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4667 57 break;
4668
4669 case 15:
4670 case l_up:
4671 81 dx = dx1-s;
4672 81 dy = dy1-s;
4673
3/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 1 times.
161 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4675 81 break;
4676
4677 default:
4678 db=99;
4679 return true;
4680 }
4681
4682 562 return ok;
4683 562 }
4684
4685
4686
4687
4688 // returns true if next step is ok, false if there is something there
4689 7351084 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4690 {
4691 7351084 bool ok = false; //initialise the var, son't just declare it
4692 7351084 int32_t dx = 0, dy = 0;
4693 7351084 int32_t sv = 8;
4694 7351084 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4695 //Why is this here??? Why is it needed???
4696 7351084 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7351084 times.
7351084 int32_t usexoffs = (SIZEflags&OVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7351084 times.
7351084 int32_t useyoffs = (SIZEflags&OVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4699
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7351071 times.
7351084 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4700
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 7351071 times.
7351084 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4701 7351084 bool offgrid = OFFGRID_ENEMY;
4702
2/2
✓ Branch 0 taken 7291 times.
✓ Branch 1 taken 7343793 times.
7351084 if(!offgrid)
4703 {
4704 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4705
1/2
✓ Branch 0 taken 7343793 times.
✗ Branch 1 not taken.
7343793 if(usehei<16)usehei=16;
4706
1/2
✓ Branch 0 taken 7343793 times.
✗ Branch 1 not taken.
7343793 if(usewid<16)usewid=16;
4707 7343793 }
4708
9/9
✓ Branch 0 taken 1329862 times.
✓ Branch 1 taken 1106072 times.
✓ Branch 2 taken 1225793 times.
✓ Branch 3 taken 1216675 times.
✓ Branch 4 taken 540167 times.
✓ Branch 5 taken 641835 times.
✓ Branch 6 taken 603222 times.
✓ Branch 7 taken 567744 times.
✓ Branch 8 taken 119714 times.
7351084 switch(ndir) //need to check every 8 pixels between two points
4709 {
4710 case 8:
4711 case up:
4712 {
4713
4/4
✓ Branch 0 taken 150833 times.
✓ Branch 1 taken 1179029 times.
✓ Branch 2 taken 150173 times.
✓ Branch 3 taken 660 times.
1329862 if(enemycanfall(id) && isSideViewGravity())
4714 660 return false;
4715
4716 1329202 dy = dy1-s;
4717
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 1328722 times.
1329202 special = (special==spw_clipbottomright)?spw_none:special;
4718 1329202 tries = usewid/(offgrid ? 8 : 16);
4719
4720
2/2
✓ Branch 0 taken 1129338 times.
✓ Branch 1 taken 1329852 times.
2459190 for ( ; tries > 0; --tries )
4721 {
4722
2/2
✓ Branch 0 taken 197240 times.
✓ Branch 1 taken 1132612 times.
1329852 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4723 1329852 try_x += (offgrid ? 8 : 16);
4724
2/2
✓ Branch 0 taken 1129988 times.
✓ Branch 1 taken 199864 times.
1329852 if (!ok) break;
4725 1129988 }
4726
2/2
✓ Branch 0 taken 1129338 times.
✓ Branch 1 taken 199864 times.
1329202 if(!ok) break;
4727
1/2
✓ Branch 0 taken 1129338 times.
✗ Branch 1 not taken.
1129338 if((usewid%16)>0) //Uneven width
4728 {
4729 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4730 }
4731 1129338 break;
4732 }
4733 case 12:
4734 case down:
4735 {
4736
4/4
✓ Branch 0 taken 180694 times.
✓ Branch 1 taken 925378 times.
✓ Branch 2 taken 179968 times.
✓ Branch 3 taken 726 times.
1106072 if(enemycanfall(id) && isSideViewGravity())
4737 726 return false;
4738
4739 1105346 dy = dy2+s;
4740 1105346 tries = usewid/(offgrid ? 8 : 16);
4741
2/2
✓ Branch 0 taken 899411 times.
✓ Branch 1 taken 1106130 times.
2005541 for ( ; tries > 0; --tries )
4742 {
4743
3/4
✓ Branch 0 taken 205187 times.
✓ Branch 1 taken 900943 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 900943 times.
1106130 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4744 1106130 try_x += (offgrid ? 8 : 16);
4745
2/2
✓ Branch 0 taken 900195 times.
✓ Branch 1 taken 205935 times.
1106130 if (!ok) break;
4746 900195 }
4747
2/2
✓ Branch 0 taken 899411 times.
✓ Branch 1 taken 205935 times.
1105346 if(!ok) break;
4748
1/2
✓ Branch 0 taken 899411 times.
✗ Branch 1 not taken.
899411 if((usewid%16)>0) //Uneven width
4749 {
4750 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4751 }
4752 899411 break;
4753 }
4754 case 14:
4755 case left:
4756 {
4757 1225793 dx = dx1-s;
4758 1225793 sv = ((isSideViewGravity())?7:0);
4759
4/4
✓ Branch 0 taken 1225170 times.
✓ Branch 1 taken 623 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 1223402 times.
1225793 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4760 1225793 tries = usehei/(offgrid ? 8 : 16);
4761
2/2
✓ Branch 0 taken 1027149 times.
✓ Branch 1 taken 1226710 times.
2253859 for ( ; tries > 0; --tries )
4762 {
4763
2/2
✓ Branch 0 taken 197459 times.
✓ Branch 1 taken 1029251 times.
1226710 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4764 1226710 try_y += (offgrid ? 8 : 16);
4765
2/2
✓ Branch 0 taken 1028066 times.
✓ Branch 1 taken 198644 times.
1226710 if (!ok) break;
4766 1028066 }
4767
2/2
✓ Branch 0 taken 1027149 times.
✓ Branch 1 taken 198644 times.
1225793 if(!ok) break;
4768
1/2
✓ Branch 0 taken 1027149 times.
✗ Branch 1 not taken.
1027149 if((usehei%16)>0) //Uneven height
4769 {
4770 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4771 }
4772 1027149 break;
4773 }
4774 case 10:
4775 case right:
4776 {
4777 1216675 dx = dx2+s;
4778 1216675 sv = ((isSideViewGravity())?7:0);
4779 1216675 tries = usehei/(offgrid ? 8 : 16);
4780
2/2
✓ Branch 0 taken 1028694 times.
✓ Branch 1 taken 1217569 times.
2246263 for ( ; tries > 0; --tries )
4781 {
4782
3/4
✓ Branch 0 taken 186626 times.
✓ Branch 1 taken 1030943 times.
✓ Branch 2 taken 1030943 times.
✗ Branch 3 not taken.
1217569 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4783 1217569 try_y += (offgrid ? 8 : 16);
4784
2/2
✓ Branch 0 taken 1029588 times.
✓ Branch 1 taken 187981 times.
1217569 if (!ok) break;
4785 1029588 }
4786
2/2
✓ Branch 0 taken 1028694 times.
✓ Branch 1 taken 187981 times.
1216675 if(!ok) break;
4787
1/2
✓ Branch 0 taken 1028694 times.
✗ Branch 1 not taken.
1028694 if((usehei%16)>0) //Uneven height
4788 {
4789 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4790 }
4791 1028694 break;
4792 }
4793 case 9:
4794 case r_up:
4795 {
4796 540167 dx = dx2+s;
4797 540167 dy = dy1-s;
4798 540167 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4799 540167 sv = ((isSideViewGravity())?7:0);
4800
2/2
✓ Branch 0 taken 523115 times.
✓ Branch 1 taken 540167 times.
1063282 for ( ; tries_x > 0; --tries_x )
4801 {
4802 540167 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4803 540167 try_y = 0;
4804
2/2
✓ Branch 0 taken 523115 times.
✓ Branch 1 taken 540167 times.
1063282 for ( ; tries_y > 0; --tries_y )
4805 {
4806
4/4
✓ Branch 0 taken 531901 times.
✓ Branch 1 taken 8266 times.
✓ Branch 2 taken 526456 times.
✓ Branch 3 taken 5445 times.
1066623 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4807
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 524064 times.
526456 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4808 540167 try_y += (offgrid ? 8 : 16);
4809
2/2
✓ Branch 0 taken 523115 times.
✓ Branch 1 taken 17052 times.
540167 if (!ok) break;
4810 523115 }
4811
2/2
✓ Branch 0 taken 523115 times.
✓ Branch 1 taken 17052 times.
540167 if (!ok) break;
4812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 523115 times.
523115 if((usehei%16)>0) //Uneven height
4813 {
4814 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4815 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4816 }
4817 523115 try_x += (offgrid ? 8 : 16);
4818 523115 }
4819
2/2
✓ Branch 0 taken 523115 times.
✓ Branch 1 taken 17052 times.
540167 if(!ok) break;
4820
1/2
✓ Branch 0 taken 523115 times.
✗ Branch 1 not taken.
523115 if((usewid%16)>0) //Uneven width
4821 {
4822 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4823 try_y = 0;
4824 for ( ; tries_y > 0; --tries_y )
4825 {
4826 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4827 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4828 try_y += (offgrid ? 8 : 16);
4829 if (!ok) break;
4830 }
4831 if (!ok) break;
4832 if((usehei%16)>0) //Uneven height
4833 {
4834 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4835 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4836 }
4837 }
4838 523115 break;
4839 }
4840 case 11:
4841 case r_down:
4842 {
4843 641835 dx = dx2+s;
4844 641835 dx = dy2+s;
4845 641835 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4846 //sv = ((isSideViewGravity())?7:0);
4847
2/2
✓ Branch 0 taken 626444 times.
✓ Branch 1 taken 641835 times.
1268279 for ( ; tries_x > 0; --tries_x )
4848 {
4849 641835 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4850 641835 try_y = 0;
4851
2/2
✓ Branch 0 taken 626444 times.
✓ Branch 1 taken 641835 times.
1268279 for ( ; tries_y > 0; --tries_y )
4852 {
4853
4/4
✓ Branch 0 taken 640324 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 627511 times.
✓ Branch 3 taken 12813 times.
1269346 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4854
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 627405 times.
627511 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4855 641835 try_y += (offgrid ? 8 : 16);
4856
2/2
✓ Branch 0 taken 626444 times.
✓ Branch 1 taken 15391 times.
641835 if (!ok) break;
4857 626444 }
4858
2/2
✓ Branch 0 taken 626444 times.
✓ Branch 1 taken 15391 times.
641835 if (!ok) break;
4859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626444 times.
626444 if((usehei%16)>0) //Uneven height
4860 {
4861 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4862 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4863 }
4864 626444 try_x += (offgrid ? 8 : 16);
4865 626444 }
4866
2/2
✓ Branch 0 taken 626444 times.
✓ Branch 1 taken 15391 times.
641835 if(!ok) break;
4867
1/2
✓ Branch 0 taken 626444 times.
✗ Branch 1 not taken.
626444 if((usewid%16)>0) //Uneven width
4868 {
4869 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4870 try_y = 0;
4871 for ( ; tries_y > 0; --tries_y )
4872 {
4873 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4874 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4875 try_y += (offgrid ? 8 : 16);
4876 if (!ok) break;
4877 }
4878 if (!ok) break;
4879 if((usehei%16)>0) //Uneven height
4880 {
4881 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4882 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4883 }
4884 }
4885 626444 break;
4886 }
4887 case 13:
4888 case l_down:
4889 {
4890 603222 dx = dx1-s;
4891 603222 dy = dy2+s;
4892 603222 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4893 //sv = ((isSideViewGravity())?7:0);
4894
2/2
✓ Branch 0 taken 586157 times.
✓ Branch 1 taken 603222 times.
1189379 for ( ; tries_x > 0; --tries_x )
4895 {
4896 603222 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4897 603222 try_y = 0;
4898
2/2
✓ Branch 0 taken 586157 times.
✓ Branch 1 taken 603222 times.
1189379 for ( ; tries_y > 0; --tries_y )
4899 {
4900
4/4
✓ Branch 0 taken 591291 times.
✓ Branch 1 taken 11931 times.
✓ Branch 2 taken 587025 times.
✓ Branch 3 taken 4266 times.
1190247 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4901
2/2
✓ Branch 0 taken 568 times.
✓ Branch 1 taken 586457 times.
587025 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4902 603222 try_y += (offgrid ? 8 : 16);
4903
2/2
✓ Branch 0 taken 586157 times.
✓ Branch 1 taken 17065 times.
603222 if (!ok) break;
4904 586157 }
4905
2/2
✓ Branch 0 taken 586157 times.
✓ Branch 1 taken 17065 times.
603222 if (!ok) break;
4906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586157 times.
586157 if((usehei%16)>0) //Uneven height
4907 {
4908 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4909 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4910 }
4911 586157 try_x += (offgrid ? 8 : 16);
4912 586157 }
4913
2/2
✓ Branch 0 taken 586157 times.
✓ Branch 1 taken 17065 times.
603222 if(!ok) break;
4914
1/2
✓ Branch 0 taken 586157 times.
✗ Branch 1 not taken.
586157 if((usewid%16)>0) //Uneven width
4915 {
4916 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4917 try_y = 0;
4918 for ( ; tries_y > 0; --tries_y )
4919 {
4920 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4921 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4922 try_y += (offgrid ? 8 : 16);
4923 if (!ok) break;
4924 }
4925 if (!ok) break;
4926 if((usehei%16)>0) //Uneven height
4927 {
4928 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4929 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4930 }
4931 }
4932 586157 break;
4933 }
4934 case 15:
4935 case l_up:
4936 {
4937 567744 dx = dx1-s;
4938 567744 dy = dy1-s;
4939 567744 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4940 567744 sv = ((isSideViewGravity())?7:0);
4941
2/2
✓ Branch 0 taken 551815 times.
✓ Branch 1 taken 567744 times.
1119559 for ( ; tries_x > 0; --tries_x )
4942 {
4943 567744 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4944 567744 try_y = 0;
4945
2/2
✓ Branch 0 taken 551815 times.
✓ Branch 1 taken 567744 times.
1119559 for ( ; tries_y > 0; --tries_y )
4946 {
4947
4/4
✓ Branch 0 taken 559085 times.
✓ Branch 1 taken 8659 times.
✓ Branch 2 taken 555123 times.
✓ Branch 3 taken 3962 times.
1122867 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4948
2/2
✓ Branch 0 taken 2439 times.
✓ Branch 1 taken 552684 times.
555123 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4949 567744 try_y += (offgrid ? 8 : 16);
4950
2/2
✓ Branch 0 taken 551815 times.
✓ Branch 1 taken 15929 times.
567744 if (!ok) break;
4951 551815 }
4952
2/2
✓ Branch 0 taken 551815 times.
✓ Branch 1 taken 15929 times.
567744 if (!ok) break;
4953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 551815 times.
551815 if((usehei%16)>0) //Uneven height
4954 {
4955 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4956 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4957 }
4958 551815 try_x += (offgrid ? 8 : 16);
4959 551815 }
4960
2/2
✓ Branch 0 taken 551815 times.
✓ Branch 1 taken 15929 times.
567744 if(!ok) break;
4961
1/2
✓ Branch 0 taken 551815 times.
✗ Branch 1 not taken.
551815 if((usewid%16)>0) //Uneven width
4962 {
4963 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4964 try_y = 0;
4965 for ( ; tries_y > 0; --tries_y )
4966 {
4967 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4968 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4969 try_y += (offgrid ? 8 : 16);
4970 if (!ok) break;
4971 }
4972 if (!ok) break;
4973 if((usehei%16)>0) //Uneven height
4974 {
4975 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4976 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4977 }
4978 }
4979 551815 break;
4980 }
4981 default:
4982 119714 db=99;
4983 119714 return true;
4984 }
4985
4986 7229984 return ok;
4987 7351084 }
4988
4989
4990 4647915 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4991 {
4992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4647915 times.
4647915 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
4993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4647915 times.
4647915 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4994
1/2
✓ Branch 0 taken 4647915 times.
✗ Branch 1 not taken.
4647915 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4995
1/2
✓ Branch 0 taken 4647915 times.
✗ Branch 1 not taken.
4647915 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4996 4647915 --usewid;
4997 4647915 --usehei;
4998 4647915 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4999 }
5000
5001 1241466 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5002 {
5003 1241466 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5004
5005
4/4
✓ Branch 0 taken 6819 times.
✓ Branch 1 taken 1234647 times.
✓ Branch 2 taken 5021 times.
✓ Branch 3 taken 1798 times.
1241466 if(special==spw_clipright&&ndir==right)
5006 {
5007 1798 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5008 1798 }
5009
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1241461 times.
1241466 int32_t usewid = (SIZEflags&OVERRIDE_HIT_WIDTH) ? hit_width : 16;
5010
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1241461 times.
1241466 int32_t usehei = (SIZEflags&OVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5011
1/2
✓ Branch 0 taken 1241466 times.
✗ Branch 1 not taken.
1241466 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5012
1/2
✓ Branch 0 taken 1241466 times.
✗ Branch 1 not taken.
1241466 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5013 1241466 --usewid;
5014 1241466 --usehei;
5015
2/2
✓ Branch 0 taken 716190 times.
✓ Branch 1 taken 525276 times.
1241466 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5016 }
5017
5018 136140 bool enemy::canmove(int32_t ndir, bool kb)
5019 {
5020 136140 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5021 }
5022
5023 // 8-directional
5024 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5025 {
5026 562 int32_t ndir=0;
5027
5028 // can move straight, check if it wants to turn
5029
2/2
✓ Branch 0 taken 549 times.
✓ Branch 1 taken 13 times.
562 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5030 {
5031
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5032 {
5033 int32_t w = Lwpns.idFirst(wBait);
5034
5035 if(w>=0)
5036 {
5037 int32_t bx = Lwpns.spr(w)->x;
5038 int32_t by = Lwpns.spr(w)->y;
5039
5040 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5041
5042 if(abs(int32_t(y)-by)>14)
5043 {
5044 if(ndir>0) // Already left or right
5045 {
5046 // Making the diagonal directions
5047 ndir += (by<y) ? 2 : 4;
5048 }
5049 else
5050 {
5051 ndir = (by<y) ? up : down;
5052 }
5053 }
5054
5055 if(canmove(ndir,special,false))
5056 {
5057 dir=ndir;
5058 return;
5059 }
5060 }
5061 }
5062
5063 // Homing added.
5064
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
549 if(newhoming && (zc_oldrand()&255)<newhoming)
5065 {
5066 ndir = lined_up(8,true);
5067
5068 if(ndir>=0 && canmove(ndir,special,false))
5069 {
5070 dir=ndir;
5071 }
5072
5073 return;
5074 }
5075
5076 549 int32_t r=zc_oldrand();
5077
5078
2/4
✓ Branch 0 taken 549 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 549 times.
549 if(newrate>0 && !(r%newrate))
5079 {
5080 549 ndir = ((dir+((r&64)?-1:1))&7)+8;
5081 549 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5082
5083
2/2
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
549 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5084 525 dir=ndir;
5085
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 19 times.
24 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5086 19 dir=ndir2;
5087
5088
3/4
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 525 times.
✗ Branch 3 not taken.
549 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5089 // due to numerous lost fractional components. -L
5090 {
5091 x.doFloor();
5092 y.doFloor();
5093 }
5094 549 }
5095
5096 549 return;
5097 }
5098
5099 // can't move straight, must turn
5100 13 int32_t i=0;
5101
5102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 for(; i<32; i++) // Try random dir
5103 {
5104 20 ndir=(zc_oldrand()&7)+8;
5105
5106
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13 times.
20 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5107 13 break;
5108 7 }
5109
5110
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(i==32)
5111 {
5112 for(ndir=8; ndir<16; ndir++)
5113 {
5114 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5115 goto ok;
5116 }
5117
5118 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5119 }
5120
5121 ok:
5122 13 dir=ndir;
5123 13 x.doFloor();
5124 13 y.doFloor();
5125 562 }
5126
5127 580199 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5128 {
5129 580199 int32_t ndir=0;
5130
5131 // can move straight, check if it wants to turn
5132
2/2
✓ Branch 0 taken 547559 times.
✓ Branch 1 taken 32640 times.
580199 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5133 {
5134
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 547352 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
547559 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5135 {
5136 101 int32_t i = Lwpns.idFirst(wBait);
5137
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5138 {
5139 weapon *w = (weapon*)Lwpns.spr(i);
5140 if (get_qr(qr_FIND_CLOSEST_BAIT))
5141 {
5142 int32_t currentrange;
5143 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5144 else currentrange = -1;
5145 int curid = i;
5146 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5147 for(; i<Lwpns.Count(); ++i)
5148 {
5149 weapon *lw = (weapon*)Lwpns.spr(i);
5150 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5151 {
5152 currentrange = distance(x, y, lw->x, lw->y);
5153 curid = i;
5154 }
5155 }
5156 i = curid;
5157 if (currentrange == -1) i = -1;
5158 }
5159 else
5160 {
5161 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5162 }
5163 if(i>=0)
5164 {
5165 int32_t bx = Lwpns.spr(i)->x;
5166 int32_t by = Lwpns.spr(i)->y;
5167
5168 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5169
5170 if(abs(int32_t(y)-by)>14)
5171 {
5172 if(ndir>0) // Already left or right
5173 {
5174 // Making the diagonal directions
5175 ndir += (by<y) ? 2 : 4;
5176 }
5177 else
5178 {
5179 ndir = (by<y) ? up : down;
5180 }
5181 }
5182 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5183 if(canmove(ndir,special,false))
5184 {
5185 dir=ndir;
5186 return;
5187 }
5188 }
5189 }
5190 101 }
5191
5192 // Homing added.
5193
4/4
✓ Branch 0 taken 29626 times.
✓ Branch 1 taken 517933 times.
✓ Branch 2 taken 15410 times.
✓ Branch 3 taken 14216 times.
547559 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5194 {
5195 14216 ndir = lined_up(8,true);
5196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14216 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14216 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5197
4/4
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 4771 times.
✓ Branch 2 taken 3593 times.
✓ Branch 3 taken 5852 times.
14216 if(ndir>=0 && canmove(ndir,special,false))
5198 {
5199 5852 dir=ndir;
5200 5852 }
5201
5202 14216 return;
5203 }
5204
5205 533343 int32_t r=zc_oldrand();
5206
5207
4/4
✓ Branch 0 taken 339542 times.
✓ Branch 1 taken 193801 times.
✓ Branch 2 taken 179436 times.
✓ Branch 3 taken 160106 times.
533343 if(newrate>0 && !(r%newrate))
5208 {
5209 160106 ndir = ((dir+((r&64)?-1:1))&7)+8;
5210 160106 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5211
5212
2/2
✓ Branch 0 taken 154306 times.
✓ Branch 1 taken 5800 times.
160106 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5213 154306 dir=ndir;
5214
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 4943 times.
5800 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5215 4943 dir=ndir2;
5216
5217
4/4
✓ Branch 0 taken 154306 times.
✓ Branch 1 taken 5800 times.
✓ Branch 2 taken 146980 times.
✓ Branch 3 taken 7326 times.
160106 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5218 // due to numerous lost fractional components. -L
5219 {
5220 7326 x.doFloor();
5221 7326 y.doFloor();
5222 7326 }
5223 160106 }
5224
5225 533343 return;
5226 }
5227
5228 // can't move straight, must turn
5229 32640 int32_t i=0;
5230
5231 // TODO: speed this up!
5232
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 61111 times.
61181 for(; i<32; i++) // Try random dir
5233 {
5234 61111 ndir=(zc_oldrand()&7)+8;
5235
5236
2/2
✓ Branch 0 taken 28541 times.
✓ Branch 1 taken 32570 times.
61111 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5237 32570 break;
5238 28541 }
5239
5240
2/2
✓ Branch 0 taken 32570 times.
✓ Branch 1 taken 70 times.
32693 if(i==32)
5241 {
5242
2/2
✓ Branch 0 taken 461 times.
✓ Branch 1 taken 53 times.
514 for(ndir=8; ndir<16; ndir++)
5243 {
5244
2/2
✓ Branch 0 taken 444 times.
✓ Branch 1 taken 17 times.
461 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5245 17 goto ok;
5246 444 }
5247
5248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5249 53 }
5250
5251 ok:
5252 32640 dir=ndir;
5253 32640 x.doFloor();
5254 32640 y.doFloor();
5255 580199 }
5256
5257 573732 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5258 {
5259 573732 newdir_8(newrate,newhoming,special,0,-8,15,15);
5260 573732 }
5261
5262 562 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5263 {
5264 562 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5265 562 }
5266
5267 // makes the enemy slide backwards when hit
5268 // sclk: first byte is clk, second byte is dir
5269 // makes the enemy slide backwards when hit
5270 // sclk: first byte is clk, second byte is dir
5271 15602028 int32_t enemy::slide()
5272 {
5273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15602028 times.
15602028 if(script_knockback_clk!=0) //scripted knockback
5274 {
5275 sclk = 0;
5276 return 1; //scripted knockback ran
5277 }
5278
5/6
✓ Branch 0 taken 101966 times.
✓ Branch 1 taken 15500062 times.
✓ Branch 2 taken 7846 times.
✓ Branch 3 taken 94120 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7846 times.
15602028 if(sclk==0 || (hp<=0 && !immortal))
5279 15507908 return 0;
5280
5281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94120 times.
94120 if(knockbackflags & FLAG_NOSLIDE)
5282 {
5283 sclk = 0;
5284 if(!OFFGRID_ENEMY)
5285 {
5286 //Fix to grid
5287 do_fix(x, 16, true);
5288 do_fix(y, 16, true);
5289 }
5290 return 0;
5291 }
5292
8/10
✓ Branch 0 taken 9542 times.
✓ Branch 1 taken 84578 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 9244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 298 times.
✓ Branch 6 taken 7093 times.
✓ Branch 7 taken 2151 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 298 times.
94120 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5293 {
5294 2151 sclk=0;
5295 2151 return 0;
5296 }
5297
5298 91969 --sclk;
5299
5300
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10528 times.
✓ Branch 2 taken 12280 times.
✓ Branch 3 taken 31718 times.
✓ Branch 4 taken 35658 times.
91969 switch(sclk>>8)
5301 {
5302 case up:
5303 {
5304
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9438 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 10521 times.
10528 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5305 {
5306 7 sclk=0;
5307 7 return 0;
5308 }
5309
4/4
✓ Branch 0 taken 1090 times.
✓ Branch 1 taken 9431 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 175 times.
10521 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5310
5311 10346 break;
5312 }
5313 case down:
5314 {
5315
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12278 times.
12280 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5316 {
5317 2 sclk=0;
5318 2 return 0;
5319 }
5320
4/4
✓ Branch 0 taken 1069 times.
✓ Branch 1 taken 11209 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 146 times.
12278 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5321
5322 12132 break;
5323 }
5324 case left:
5325 {
5326
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29364 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 31705 times.
31718 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5327 {
5328 13 sclk=0;
5329 13 return 0;
5330 }
5331
4/4
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 29351 times.
✓ Branch 2 taken 2116 times.
✓ Branch 3 taken 238 times.
31705 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5332
5333 31467 break;
5334 }
5335 case right:
5336 {
5337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35658 times.
35658 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5338 {
5339 sclk=0;
5340 return 0;
5341 }
5342
4/4
✓ Branch 0 taken 3288 times.
✓ Branch 1 taken 32370 times.
✓ Branch 2 taken 3018 times.
✓ Branch 3 taken 270 times.
35658 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5343 35388 break;
5344 }
5345 }
5346
5347 91118 int32_t move = knockbackSpeed;
5348
2/2
✓ Branch 0 taken 86238 times.
✓ Branch 1 taken 91118 times.
177356 while(move>0)
5349 {
5350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91118 times.
91118 int32_t thismove = zc_min(8, move);
5351 91118 move -= thismove;
5352 91118 hitdir = (sclk>>8);
5353
5/5
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 10346 times.
✓ Branch 2 taken 12132 times.
✓ Branch 3 taken 31467 times.
✓ Branch 4 taken 35388 times.
91118 switch(sclk>>8)
5354 {
5355 case up:
5356 10346 y-=thismove;
5357 10346 break;
5358
5359 case down:
5360 12132 y+=thismove;
5361 12132 break;
5362
5363 case left:
5364 31467 x-=thismove;
5365 31467 break;
5366
5367 case right:
5368 35388 x+=thismove;
5369 35388 break;
5370 }
5371
2/2
✓ Branch 0 taken 86238 times.
✓ Branch 1 taken 4880 times.
91118 if(!canmove(sclk>>8,(zfix)0,0,true))
5372 {
5373
3/3
✓ Branch 0 taken 1970 times.
✓ Branch 1 taken 2906 times.
✓ Branch 2 taken 4 times.
4880 switch(sclk>>8)
5374 {
5375 case up:
5376 case down:
5377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1970 times.
1970 if(y < 0)
5378 y = 0;
5379
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 1645 times.
1970 else if((int32_t(y)&15) > 7)
5380 325 y = TRUNCATE_TILE(int32_t(y)) + 16;
5381 else
5382 1645 y = TRUNCATE_TILE(int32_t(y));
5383
5384 1970 break;
5385
5386 case left:
5387 case right:
5388
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2902 times.
2906 if(x < 0)
5389 4 x = 0;
5390
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 2069 times.
2902 else if((int32_t(x)&15) > 7)
5391 833 x = TRUNCATE_TILE(int32_t(x)) + 16;
5392 else
5393 2069 x = TRUNCATE_TILE(int32_t(x));
5394
5395 2906 break;
5396 }
5397
5398 4880 sclk=0;
5399 4880 clk3=0;
5400 4880 break;
5401 }
5402 }
5403
5404
2/2
✓ Branch 0 taken 83765 times.
✓ Branch 1 taken 7353 times.
91118 if((sclk&255)==0)
5405 {
5406 //hitdir = -1;
5407 7353 sclk=0;
5408 7353 }
5409 91118 return 2;
5410 15602028 }
5411
5412 bool enemy::can_slide()
5413 {
5414 if(sclk==0 || (hp<=0 && !immortal))
5415 return false;
5416
5417 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5418 {
5419 return false;
5420 }
5421
5422 return true;
5423 }
5424
5425 bool enemy::fslide()
5426 {
5427 if(sclk==0 || (hp<=0 && !immortal))
5428 return false;
5429
5430 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5431 {
5432 sclk=0;
5433 return false;
5434 }
5435
5436 --sclk;
5437
5438 switch(sclk>>8)
5439 {
5440 case up:
5441 if(y<=16)
5442 {
5443 sclk=0;
5444 return false;
5445 }
5446
5447 break;
5448
5449 case down:
5450 if(y>=world_h-16)
5451 {
5452 sclk=0;
5453 return false;
5454 }
5455
5456 break;
5457
5458 case left:
5459 if(x<=16)
5460 {
5461 sclk=0;
5462 return false;
5463 }
5464
5465 break;
5466
5467 case right:
5468 if(x>=world_w-16)
5469 {
5470 sclk=0;
5471 return false;
5472 }
5473
5474 break;
5475 }
5476 hitdir = (sclk>>8);
5477 switch(sclk>>8)
5478 {
5479 case up:
5480 y-=4;
5481 break;
5482
5483 case down:
5484 y+=4;
5485 break;
5486
5487 case left:
5488 x-=4;
5489 break;
5490
5491 case right:
5492 x+=4;
5493 break;
5494 }
5495
5496 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5497 {
5498 switch(sclk>>8)
5499 {
5500 case up:
5501 case down:
5502 if((int32_t(y)&15) > 7)
5503 y = TRUNCATE_TILE(int32_t(y)) + 16;
5504 else
5505 y = TRUNCATE_TILE(int32_t(y));
5506
5507 break;
5508
5509 case left:
5510 case right:
5511 if((int32_t(x)&15) > 7)
5512 x = TRUNCATE_TILE(int32_t(x)) + 16;
5513 else
5514 x = TRUNCATE_TILE(int32_t(x));
5515
5516 break;
5517 }
5518
5519 sclk=0;
5520 clk3=0;
5521 }
5522
5523 if((sclk&255)==0)
5524 sclk=0;
5525
5526 return true;
5527 }
5528
5529 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5530 {
5531 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5532 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5533 bool ret = sprite::knockback(time, dir, speed);
5534 if(ret) sclk = 0; //kill engine knockback if interrupted
5535 //! Perhaps also set hitdir here, if needed for timing? -Z
5536 return ret;
5537 }
5538
5539 37848162 bool enemy::runKnockback()
5540 {
5541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37848162 times.
37848162 if((script_knockback_clk&0xFF)==0)
5542 {
5543 37848162 script_knockback_clk = 0;
5544 37848162 return false;
5545 }
5546 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5547 {
5548 return false;
5549 }
5550 int32_t move = script_knockback_speed;
5551 int32_t kb_dir = script_knockback_clk>>8;
5552 --script_knockback_clk;
5553
5554 while(move>0)
5555 {
5556 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5557 move -= thismove;
5558 hitdir = kb_dir;
5559 switch(kb_dir)
5560 {
5561 case r_up:
5562 case l_up:
5563 case up:
5564 y-=thismove;
5565 break;
5566
5567 case r_down:
5568 case l_down:
5569 case down:
5570 y+=thismove;
5571 break;
5572 }
5573 switch(kb_dir)
5574 {
5575 case l_up:
5576 case l_down:
5577 case left:
5578 x-=thismove;
5579 break;
5580
5581 case r_up:
5582 case r_down:
5583 case right:
5584 x+=thismove;
5585 break;
5586 }
5587 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5588 {
5589 if(!canmove(kb_dir,(zfix)0,0,true))
5590 {
5591 script_knockback_clk=0;
5592 clk3=0;
5593 //Fix to grid
5594 switch(kb_dir)
5595 {
5596 case up:
5597 case down:
5598 break;
5599 default:
5600 if(x < 0)
5601 x = 0;
5602 else if((int32_t(x)&15) > 7)
5603 x = TRUNCATE_TILE(int32_t(x)) + 16;
5604 else
5605 x = TRUNCATE_TILE(int32_t(x));
5606 break;
5607 }
5608 switch(kb_dir)
5609 {
5610 case left:
5611 case right:
5612 break;
5613 default:
5614 if(y < 0)
5615 y = 0;
5616 else if((int32_t(y)&15) > 7)
5617 y = TRUNCATE_TILE(int32_t(y)) + 16;
5618 else
5619 y = TRUNCATE_TILE(int32_t(y));
5620 break;
5621 }
5622 break;
5623 }
5624 }
5625 else
5626 {
5627 if(!scr_canplace(x,y,0,true))
5628 {
5629 script_knockback_clk=0;
5630 clk3=0;
5631 //Fix to grid
5632 if (OFFGRID_ENEMY)
5633 {
5634 switch(kb_dir)
5635 {
5636 case up:
5637 case down:
5638 break;
5639 default:
5640 if(x < 0)
5641 x = 0;
5642 else if((int32_t(x)&7) > 3)
5643 x = TRUNCATE_HALF_TILE(int32_t(x)) + 8;
5644 else
5645 x = TRUNCATE_HALF_TILE(int32_t(x));
5646 break;
5647 }
5648 switch(kb_dir)
5649 {
5650 case left:
5651 case right:
5652 break;
5653 default:
5654 if(y < 0)
5655 y = 0;
5656 else if((int32_t(y)&7) > 3)
5657 y = TRUNCATE_HALF_TILE(int32_t(y)) + 8;
5658 else
5659 y = TRUNCATE_HALF_TILE(int32_t(y));
5660 break;
5661 }
5662 }
5663 else
5664 {
5665 switch(kb_dir)
5666 {
5667 case up:
5668 case down:
5669 break;
5670 default:
5671 if(x < 0)
5672 x = 0;
5673 else if((int32_t(x)&15) > 7)
5674 x = TRUNCATE_TILE(int32_t(x)) + 16;
5675 else
5676 x = TRUNCATE_TILE(int32_t(x));
5677 break;
5678 }
5679 switch(kb_dir)
5680 {
5681 case left:
5682 case right:
5683 break;
5684 default:
5685 if(y < 0)
5686 y = 0;
5687 else if((int32_t(y)&15) > 7)
5688 y = TRUNCATE_TILE(int32_t(y)) + 16;
5689 else
5690 y = TRUNCATE_TILE(int32_t(y));
5691 break;
5692 }
5693 }
5694 break;
5695 }
5696
5697 }
5698 }
5699 return true;
5700 37848162 }
5701 // changes enemy's direction, checking restrictions
5702 // rate: 0 = no random changes, 16 = always random change
5703 // homing: 0 = none, 256 = always
5704 // grumble 0 = none, 4 = strongest appetite
5705 519324 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5706 {
5707 519324 int32_t ndir=-1;
5708
5709
4/4
✓ Branch 0 taken 110003 times.
✓ Branch 1 taken 409321 times.
✓ Branch 2 taken 37833 times.
✓ Branch 3 taken 72170 times.
519324 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble))
5710 {
5711 72170 int32_t i = Lwpns.idFirst(wBait);
5712
1/2
✓ Branch 0 taken 72170 times.
✗ Branch 1 not taken.
72170 if(i >= 0) //idfirst returns -1 if it can't find any
5713 {
5714 weapon *w = (weapon*)Lwpns.spr(i);
5715 if (get_qr(qr_FIND_CLOSEST_BAIT))
5716 {
5717 int32_t currentrange;
5718 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5719 else currentrange = -1;
5720 int curid = i;
5721 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5722 for(; i<Lwpns.Count(); ++i)
5723 {
5724 weapon *lw = (weapon*)Lwpns.spr(i);
5725 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5726 {
5727 currentrange = distance(x, y, lw->x, lw->y);
5728 curid = i;
5729 }
5730 }
5731 i = curid;
5732 if (currentrange == -1) i = -1;
5733 }
5734 else
5735 {
5736 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5737 }
5738 if (i >= 0)
5739 {
5740 int32_t bx = Lwpns.spr(i)->x;
5741 int32_t by = Lwpns.spr(i)->y;
5742
5743 if(abs(int32_t(y)-by)>14)
5744 {
5745 ndir = (by<y) ? up : down;
5746 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5747 if(canmove(ndir,special,false))
5748 {
5749 dir=ndir;
5750 return;
5751 }
5752 }
5753
5754 ndir = (bx<x) ? left : right;
5755 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & item_flag1)) ndir = oppositeDir[ndir];
5756 if(canmove(ndir,special,false))
5757 {
5758 dir=ndir;
5759 return;
5760 }
5761 }
5762 }
5763 72170 }
5764
5765
2/2
✓ Branch 0 taken 351654 times.
✓ Branch 1 taken 167670 times.
519324 if((zc_oldrand()&255)<abs(newhoming))
5766 {
5767 167670 ndir = lined_up(8,false);
5768
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167670 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167670 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5769
4/4
✓ Branch 0 taken 45272 times.
✓ Branch 1 taken 122398 times.
✓ Branch 2 taken 5699 times.
✓ Branch 3 taken 39573 times.
167670 if(ndir>=0 && canmove(ndir,special,false))
5770 {
5771 39573 dir=ndir;
5772 39573 return;
5773 }
5774 128097 }
5775
5776 479751 int32_t i=0;
5777
5778
2/2
✓ Branch 0 taken 3339 times.
✓ Branch 1 taken 1177811 times.
1181150 for(; i<32; i++)
5779 {
5780 1177811 int32_t r=zc_oldrand();
5781
5782
2/2
✓ Branch 0 taken 344022 times.
✓ Branch 1 taken 833789 times.
1177811 if((r&15)<newrate)
5783 344022 ndir=(r>>4)&3;
5784 else
5785 833789 ndir=dir;
5786
5787
2/2
✓ Branch 0 taken 701399 times.
✓ Branch 1 taken 476412 times.
1177811 if(canmove(ndir,special,false))
5788 476412 break;
5789 701399 }
5790
5791
2/2
✓ Branch 0 taken 476412 times.
✓ Branch 1 taken 3339 times.
480511 if(i==32)
5792 {
5793
2/2
✓ Branch 0 taken 8938 times.
✓ Branch 1 taken 760 times.
9698 for(ndir=0; ndir<4; ndir++)
5794 {
5795
2/2
✓ Branch 0 taken 6359 times.
✓ Branch 1 taken 2579 times.
8938 if(canmove(ndir,special,false))
5796 2579 goto ok;
5797 6359 }
5798
5799
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 700 times.
760 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5800 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5801 760 }
5802
5803 ok:
5804 479751 dir = ndir;
5805 519324 }
5806
5807 2669 void enemy::newdir()
5808 {
5809 2669 newdir(4,0,spw_none);
5810 2669 }
5811
5812 zfix enemy::distance_left()
5813 {
5814 int32_t a2=x.getInt();
5815 int32_t b2=y.getInt();
5816
5817 switch(dir)
5818 {
5819 case up:
5820 return (zfix)(b2&0xF);
5821
5822 case down:
5823 return (zfix)(16-(b2&0xF));
5824
5825 case left:
5826 return (zfix)(a2&0xF);
5827
5828 case right:
5829 return (zfix)(16-(a2&0xF));
5830 }
5831
5832 return (zfix)0;
5833 }
5834
5835 // keeps walking around
5836 384569 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5837 {
5838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384569 times.
384569 if(slide())
5839 return;
5840
5841
8/12
✓ Branch 0 taken 380735 times.
✓ Branch 1 taken 3834 times.
✓ Branch 2 taken 380735 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 376308 times.
✓ Branch 5 taken 4427 times.
✓ Branch 6 taken 376308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 376308 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 376308 times.
384569 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5842 8261 return;
5843
5844
2/2
✓ Branch 0 taken 25489 times.
✓ Branch 1 taken 350819 times.
376308 if(clk3<=0)
5845 {
5846 25489 fix_coords(true);
5847 25489 newdir(newrate,newhoming,special);
5848
5849
1/2
✓ Branch 0 taken 25489 times.
✗ Branch 1 not taken.
25489 if(step==0)
5850 clk3=0;
5851 else
5852 25489 clk3=int32_t(16.0/step);
5853 25489 }
5854
2/2
✓ Branch 0 taken 350774 times.
✓ Branch 1 taken 45 times.
350819 else if(scored)
5855 {
5856 45 dir^=1;
5857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5858 else clk3=32767;
5859 45 }
5860
5861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 376308 times.
376308 if (step != 0) --clk3;
5862 376308 move(step);
5863 384569 }
5864
5865 void enemy::constant_walk()
5866 {
5867 constant_walk(4,0,spw_none);
5868 }
5869
5870 35220 int32_t enemy::pos(int32_t newx,int32_t newy)
5871 {
5872 35220 return (newy<<8)+newx;
5873 }
5874
5875 // for variable step rates
5876 473814 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5877 {
5878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
473814 if(slide())
5879 return;
5880
5881
10/14
✓ Branch 0 taken 473814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 473814 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 465189 times.
✓ Branch 5 taken 8625 times.
✓ Branch 6 taken 455915 times.
✓ Branch 7 taken 9274 times.
✓ Branch 8 taken 418370 times.
✓ Branch 9 taken 37545 times.
✓ Branch 10 taken 418370 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 418370 times.
✗ Branch 13 not taken.
473814 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5882 55444 return;
5883
5884 418370 zfix dx = (zfix)0;
5885 418370 zfix dy = (zfix)0;
5886
5887
5/9
✓ Branch 0 taken 93441 times.
✓ Branch 1 taken 97752 times.
✓ Branch 2 taken 111603 times.
✓ Branch 3 taken 113743 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1831 times.
418370 switch(dir)
5888 {
5889 case 8:
5890 case up:
5891 93441 dy-=step;
5892 93441 break;
5893
5894 case 12:
5895 case down:
5896 97752 dy+=step;
5897 97752 break;
5898
5899 case 14:
5900 case left:
5901 111603 dx-=step;
5902 111603 break;
5903
5904 case 10:
5905 case right:
5906 113743 dx+=step;
5907 113743 break;
5908
5909 case 15:
5910 case l_up:
5911 dx-=step;
5912 dy-=step;
5913 break;
5914
5915 case 9:
5916 case r_up:
5917 dx+=step;
5918 dy-=step;
5919 break;
5920
5921 case 13:
5922 case l_down:
5923 dx-=step;
5924 dy+=step;
5925 break;
5926
5927 case 11:
5928 case r_down:
5929 dx+=step;
5930 dy+=step;
5931 break;
5932 }
5933
5934
8/8
✓ Branch 0 taken 204198 times.
✓ Branch 1 taken 214172 times.
✓ Branch 2 taken 22777 times.
✓ Branch 3 taken 181421 times.
✓ Branch 4 taken 11556 times.
✓ Branch 5 taken 11221 times.
✓ Branch 6 taken 405927 times.
✓ Branch 7 taken 12443 times.
418370 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5935 406814 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5936 {
5937 12443 fix_coords();
5938 12443 newdir(newrate,newhoming,special);
5939 12443 clk3=pos(x,y);
5940 12443 }
5941
5942 418370 move(step);
5943 473814 }
5944
5945 // pauses for a while after it makes a complete move (to a new square)
5946 12302902 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5947 {
5948
4/4
✓ Branch 0 taken 79807 times.
✓ Branch 1 taken 12223095 times.
✓ Branch 2 taken 66977 times.
✓ Branch 3 taken 12830 times.
12302902 if(sclk && clk2)
5949 {
5950 12830 clk3=0;
5951 12830 }
5952
5953
11/14
✓ Branch 0 taken 12229953 times.
✓ Branch 1 taken 72949 times.
✓ Branch 2 taken 12229953 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12229953 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11763160 times.
✓ Branch 7 taken 466793 times.
✓ Branch 8 taken 11625411 times.
✓ Branch 9 taken 137749 times.
✓ Branch 10 taken 11620875 times.
✓ Branch 11 taken 4536 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 11620875 times.
12302902 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5954 {
5955 682027 return;
5956 }
5957
5958
2/2
✓ Branch 0 taken 2132182 times.
✓ Branch 1 taken 9488693 times.
11620875 if(clk2>0)
5959 {
5960 2132182 --clk2;
5961 2132182 return;
5962 }
5963
5964
2/2
✓ Branch 0 taken 410197 times.
✓ Branch 1 taken 9078496 times.
9488693 if(clk3<=0)
5965 {
5966 410197 fix_coords(true);
5967 410197 newdir(newrate,newhoming,special);
5968 410197 clk3=int32_t(16.0/step);
5969
2/2
✓ Branch 0 taken 410000 times.
✓ Branch 1 taken 197 times.
410197 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 410197 times.
410197 if(clk2<0)
5971 {
5972 clk2=0;
5973 }
5974
2/2
✓ Branch 0 taken 54751 times.
✓ Branch 1 taken 355446 times.
410197 else if((zc_oldrand()&15)<newhrate)
5975 {
5976 54751 clk2=haltcnt;
5977 54751 return;
5978 }
5979 355446 }
5980
2/2
✓ Branch 0 taken 9075339 times.
✓ Branch 1 taken 3157 times.
9078496 else if(scored)
5981 {
5982 3157 dir^=1;
5983
5984
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3152 times.
3157 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5985 5 else clk3=32767;
5986 3157 }
5987
5988
2/2
✓ Branch 0 taken 76939 times.
✓ Branch 1 taken 9357003 times.
9433942 if (step != 0) --clk3;
5989 9433942 move(step);
5990 12302902 }
5991
5992 // 8-directional movement, aligns to 8 pixels
5993 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5994 {
5995 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5996 return;
5997
5998 if(clk3<=0)
5999 {
6000 newdir_8(newrate,newhoming,special);
6001 clk3=int32_t(8.0/step);
6002 if (step == 0) clk3 = 32767;
6003 }
6004
6005 if (step != 0) --clk3;
6006 move(step);
6007 }
6008 // 8-directional movement, aligns to 8 pixels
6009 241864 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6010 {
6011
6/12
✓ Branch 0 taken 241864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241864 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 241864 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 241864 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 241864 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 241864 times.
241864 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6012 return;
6013
6014
2/2
✓ Branch 0 taken 225663 times.
✓ Branch 1 taken 16201 times.
241864 if(clk3<=0)
6015 {
6016 16201 newdir_8(newrate,newhoming,special);
6017 16201 clk3=int32_t(8.0/step);
6018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16201 times.
16201 if (step == 0) clk3 = 32767;
6019 16201 }
6020
6021
1/2
✓ Branch 0 taken 241864 times.
✗ Branch 1 not taken.
241864 if (step != 0) --clk3;
6022 241864 move(step);
6023 241864 }
6024
6025 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6026 {
6027 if(clk<0 || dying || stunclk || watch || frozenclock)
6028 return;
6029
6030 if(!canmove(dir,step,special,false))
6031 clk3=0;
6032
6033 if(clk2>0)
6034 {
6035 --clk2;
6036 return;
6037 }
6038
6039 if(clk3<=0)
6040 {
6041 newdir_8(newrate,newhoming,special);
6042 clk3=newclk;
6043
6044 if(clk2<0)
6045 {
6046 clk2=0;
6047 }
6048 else if((zc_oldrand()&15)<newhrate)
6049 {
6050 newdir_8(newrate,newhoming,special);
6051 clk2=haltcnt;
6052 return;
6053 }
6054 }
6055
6056 --clk3;
6057 move(step);
6058 }
6059
6060 // 8-directional movement, no alignment
6061 4716566 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6062 {
6063
9/12
✓ Branch 0 taken 4507311 times.
✓ Branch 1 taken 209255 times.
✓ Branch 2 taken 4507311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4480852 times.
✓ Branch 5 taken 26459 times.
✓ Branch 6 taken 4469805 times.
✓ Branch 7 taken 11047 times.
✓ Branch 8 taken 4469805 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4469805 times.
4716566 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6064 246761 return;
6065
6066
2/2
✓ Branch 0 taken 4439338 times.
✓ Branch 1 taken 30467 times.
4469805 if(!canmove(dir,step,special,false))
6067 30467 clk3=0;
6068
6069
2/2
✓ Branch 0 taken 3912274 times.
✓ Branch 1 taken 557531 times.
4469805 if(clk3<=0)
6070 {
6071 557531 newdir_8(newrate,newhoming,special);
6072 557531 clk3=newclk;
6073 557531 }
6074
6075 4469805 --clk3;
6076 4469805 move(step);
6077 4716566 }
6078
6079 // same as above but with variable enemy size
6080 94431 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6081 {
6082
8/12
✓ Branch 0 taken 93250 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 93250 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93250 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 93199 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 93199 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 93199 times.
94431 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6083 1232 return;
6084
6085
2/2
✓ Branch 0 taken 91865 times.
✓ Branch 1 taken 1334 times.
93199 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6086 1334 clk3=0;
6087
6088
2/2
✓ Branch 0 taken 86732 times.
✓ Branch 1 taken 6467 times.
93199 if(clk3<=0)
6089 {
6090 6467 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6091 6467 clk3=newclk;
6092 6467 }
6093
6094 93199 --clk3;
6095 93199 move(step);
6096 94431 }
6097
6098 // the variable speed floater movement
6099 // ms is max speed
6100 // ss is step speed
6101 // s is step count
6102 // p is pause count
6103 // g is graduality :)
6104 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6105 4019514 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6106 {
6107 4019514 ++clk2;
6108 4019514 byte over_pit = overpit(this);
6109
6110
4/4
✓ Branch 0 taken 1114794 times.
✓ Branch 1 taken 2904720 times.
✓ Branch 2 taken 1114527 times.
✓ Branch 3 taken 267 times.
4019514 if(dmisc1 && over_pit) p = 0;
6111
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 56650 times.
✓ Branch 2 taken 1586380 times.
✓ Branch 3 taken 2243416 times.
✓ Branch 4 taken 133068 times.
4019514 switch(movestatus)
6112 {
6113 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6114 //! if the conditions prevent it, we jump back to case 2.
6115 case 0: // paused
6116
2/2
✓ Branch 0 taken 55199 times.
✓ Branch 1 taken 1451 times.
56650 if(clk2>=p)
6117 {
6118 1451 movestatus=1;
6119 1451 clk2=0;
6120 1451 }
6121
6122 56650 break;
6123
6124 case 1: // speeding up
6125
1/2
✓ Branch 0 taken 1586380 times.
✗ Branch 1 not taken.
1586380 if (s >= 0)
6126 {
6127
2/2
✓ Branch 0 taken 1575074 times.
✓ Branch 1 taken 11306 times.
1586380 if(clk2<g*s)
6128 {
6129
2/2
✓ Branch 0 taken 1473474 times.
✓ Branch 1 taken 101600 times.
1575074 if(!((clk2-1)%g))
6130 101600 step+=ss;
6131 1575074 }
6132 else
6133 {
6134 11306 movestatus=2;
6135 11306 clk2=0;
6136 }
6137 1586380 }
6138 else
6139 {
6140 if(step < ms)
6141 {
6142 if(!((clk2-1)%g))
6143 {
6144 step+=ss;
6145 if (step >= ms) step = ms;
6146 }
6147 }
6148 else
6149 {
6150 step = ms;
6151 movestatus=2;
6152 clk2=0;
6153 }
6154 }
6155
6156 1586380 break;
6157
6158 case 2: // normal
6159 2243416 step=ms;
6160
6161
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2243416 times.
✓ Branch 2 taken 481019 times.
✓ Branch 3 taken 1762397 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1762397 times.
✓ Branch 6 taken 1760147 times.
✓ Branch 7 taken 2250 times.
2243416 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6162 {
6163
1/2
✓ Branch 0 taken 2250 times.
✗ Branch 1 not taken.
2250 if (s >= 0) step=ss*s;
6164 else step=ms;
6165 2250 movestatus=3;
6166 2250 clk2=0;
6167 2250 }
6168
6169 2243416 break;
6170
6171 case 3: // slowing down
6172
1/2
✓ Branch 0 taken 133068 times.
✗ Branch 1 not taken.
133068 if (s >= 0)
6173 {
6174
2/2
✓ Branch 0 taken 131387 times.
✓ Branch 1 taken 1681 times.
133068 if(clk2<=g*s)
6175 {
6176 { //don't slow down over pits
6177
6178
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 131120 times.
131387 if(over_pit)
6179 {
6180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 if(dmisc1)
6181 {
6182 step=ms;
6183 }
6184 267 }
6185 else //can slow down
6186 {
6187
4/4
✓ Branch 0 taken 8088 times.
✓ Branch 1 taken 123032 times.
✓ Branch 2 taken 7720 times.
✓ Branch 3 taken 368 times.
131120 if(!(clk2%g) && !dmisc1)
6188 7720 step-=ss;
6189 }
6190 }
6191
6192
6193 131387 }
6194 else
6195 {
6196 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6197 //this doesn't help keese, as they have a z of 0.
6198 //they always nee to run this check.
6199 {
6200
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1681 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1681 if(over_pit &&!dmisc1)
6201 {
6202 --clk2; //if over a pit, don't land, and revert clock change
6203 }
6204 else //can land safely
6205 {
6206 1681 movestatus=0;
6207
3/4
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 566 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1115 times.
1681 if(dmisc1&&!over_pit)
6208 1115 step=0;
6209 1681 clk2=0;
6210 }
6211 }
6212
6213 }
6214 133068 }
6215 else
6216 {
6217 if(step > 0)
6218 {
6219 if(over_pit)
6220 {
6221 if(dmisc1)
6222 {
6223 step=ms;
6224 }
6225 }
6226 else //can slow down
6227 {
6228 if(!(clk2%g))
6229 step-=ss;
6230 }
6231 }
6232 else
6233 {
6234 //if((moveflags&move_can_pitfall)) //don't check pits if the enemy ignores them
6235 //this doesn't help keese, as they have a z of 0.
6236 //they always nee to run this check.
6237 if(over_pit)
6238 {
6239 step+=ss; //if over a pit, don't land, and revert clock change
6240 }
6241 else //can land safely
6242 {
6243 movestatus=0;
6244 step=0;
6245 clk2=0;
6246 }
6247 }
6248 }
6249
6250 133068 break;
6251 }
6252
6253
2/2
✓ Branch 0 taken 2252472 times.
✓ Branch 1 taken 1767042 times.
4019514 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6254 4019514 }
6255
6256 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6257 {
6258 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6259 }
6260
6261 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6262 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6263 884212 int32_t enemy::lined_up(int32_t range, bool dir8)
6264 {
6265 884212 int32_t lx = Hero.getX();
6266 884212 int32_t ly = Hero.getY();
6267
6268
2/2
✓ Branch 0 taken 37116 times.
✓ Branch 1 taken 847096 times.
884212 if(abs(lx-int32_t(x))<=range)
6269 {
6270
2/2
✓ Branch 0 taken 16326 times.
✓ Branch 1 taken 20790 times.
37116 if(ly<y)
6271 {
6272 16326 return up;
6273 }
6274
6275 20790 return down;
6276 }
6277
6278
2/2
✓ Branch 0 taken 52563 times.
✓ Branch 1 taken 794533 times.
847096 if(abs(ly-int32_t(y))<=range)
6279 {
6280
2/2
✓ Branch 0 taken 26746 times.
✓ Branch 1 taken 25817 times.
52563 if(lx<x)
6281 {
6282 26746 return left;
6283 }
6284
6285 25817 return right;
6286 }
6287
6288
2/2
✓ Branch 0 taken 159685 times.
✓ Branch 1 taken 634848 times.
794533 if(dir8)
6289 {
6290
2/2
✓ Branch 0 taken 239366 times.
✓ Branch 1 taken 395482 times.
634848 if(abs(lx-x)-abs(ly-y)<=range)
6291 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6292 {
6293
2/2
✓ Branch 0 taken 102014 times.
✓ Branch 1 taken 137352 times.
239366 if(ly<y)
6294 {
6295
2/2
✓ Branch 0 taken 53726 times.
✓ Branch 1 taken 48288 times.
102014 if(lx<x)
6296 {
6297 53726 return l_up;
6298 }
6299 else
6300 {
6301 48288 return r_up;
6302 }
6303 }
6304 else
6305 {
6306
2/2
✓ Branch 0 taken 72757 times.
✓ Branch 1 taken 64595 times.
137352 if(lx<x)
6307 {
6308 64595 return l_down;
6309 }
6310 else
6311 {
6312 72757 return r_down;
6313 }
6314 }
6315 }
6316 395482 }
6317
6318 555167 return -1;
6319 884212 }
6320
6321 // returns true if Hero is within 'range' pixels of the enemy
6322 27884 bool enemy::HeroInRange(int32_t range)
6323 {
6324 27884 int32_t lx = Hero.getX();
6325 27884 int32_t ly = Hero.getY();
6326
2/2
✓ Branch 0 taken 22775 times.
✓ Branch 1 taken 5109 times.
27884 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6327 }
6328
6329 // place the enemy in line with Hero (red wizzrobes)
6330 4899 void enemy::place_on_axis(bool floater, bool solid_ok)
6331 {
6332
6/6
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 4312 times.
✓ Branch 2 taken 4355 times.
✓ Branch 3 taken 544 times.
✓ Branch 4 taken 587 times.
✓ Branch 5 taken 3768 times.
4899 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6333
6/6
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 4460 times.
✓ Branch 2 taken 4109 times.
✓ Branch 3 taken 790 times.
✓ Branch 4 taken 439 times.
✓ Branch 5 taken 3670 times.
4899 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6334 4899 int32_t pos2=zc_oldrand()%23;
6335 4899 int32_t tried=0;
6336 4899 bool last_resort,placed=false;
6337
6338
6339 4899 do
6340 {
6341
2/2
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 3127 times.
7587 if(pos2<14)
6342 {
6343 4460 x=(pos2<<4)+16;
6344 4460 y=ly;
6345 4460 }
6346 else
6347 {
6348 3127 x=lx;
6349 3127 y=((pos2-14)<<4)+16;
6350 }
6351
6352 // Don't commit to a last resort if position is out of bounds.
6353
6/6
✓ Branch 0 taken 7248 times.
✓ Branch 1 taken 339 times.
✓ Branch 2 taken 6936 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 257 times.
✓ Branch 5 taken 6679 times.
7587 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6354
6355
4/4
✓ Branch 0 taken 3907 times.
✓ Branch 1 taken 3680 times.
✓ Branch 2 taken 4862 times.
✓ Branch 3 taken 1339 times.
7587 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6356 {
6357 // Red Wizzrobes should be able to appear on water, but not other
6358 // solid combos; however, they could appear on solid combos in 2.10,
6359 // and some quests depend on that.
6360
4/4
✓ Branch 0 taken 2341 times.
✓ Branch 1 taken 6201 times.
✓ Branch 2 taken 1302 times.
✓ Branch 3 taken 4899 times.
8542 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6361 8542 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6362 4899 placed=true;
6363 8542 }
6364
6365
3/6
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4589 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2688 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7277 if(!placed && tried>=22 && last_resort)
6366 {
6367 placed=true;
6368 }
6369
6370 7277 ++tried;
6371 7277 pos2=(pos2+3)%23;
6372
2/2
✓ Branch 0 taken 2688 times.
✓ Branch 1 taken 4589 times.
7277 }
6373 7277 while(!placed);
6374
6375
2/2
✓ Branch 0 taken 2781 times.
✓ Branch 1 taken 1808 times.
4589 if(y==ly)
6376 2781 dir=(x<lx)?right:left;
6377 else
6378 1808 dir=(y<ly)?down:up;
6379
6380 4589 clk2=tried;
6381 4589 }
6382
6383 20323537 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6384 {
6385 20323537 int32_t t = o_tile;
6386 20323537 int32_t b = o_tile;
6387
6388 // Darknuts, but also Wizzrobes and Wallmasters
6389
3/4
✓ Branch 0 taken 8417552 times.
✓ Branch 1 taken 10866215 times.
✓ Branch 2 taken 1039770 times.
✗ Branch 3 not taken.
20323537 switch(family)
6390 {
6391 case eeWALK:
6392
5/6
✓ Branch 0 taken 505407 times.
✓ Branch 1 taken 10360808 times.
✓ Branch 2 taken 367468 times.
✓ Branch 3 taken 137939 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 367468 times.
10866215 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6393 {
6394 367468 tile=s_tile;
6395 367468 t=s_tile;
6396 367468 b=s_tile;
6397 367468 }
6398
6399 10866215 break;
6400
6401 case eeTRAP:
6402
4/6
✓ Branch 0 taken 193566 times.
✓ Branch 1 taken 846204 times.
✓ Branch 2 taken 193566 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 193566 times.
1039770 if(dummy_int[1] && guysbuf[id].flags & guy_trp2 && do_animation) // Just to make sure
6403 {
6404 193566 tile=s_tile;
6405 193566 t=s_tile;
6406 193566 b=s_tile;
6407 193566 }
6408
6409 1039770 break;
6410
6411 case eeSPINTILE:
6412 if(misc>=96 && do_animation)
6413 {
6414 tile=o_tile+frames*ndir;
6415 t=tile;
6416 }
6417
6418 break;
6419 }
6420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20323537 times.
20323537 if ( do_animation )
6421 {
6422
4/6
✓ Branch 0 taken 184337 times.
✓ Branch 1 taken 20139200 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 267131 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 19872069 times.
20323537 if(ndir!=0) switch(frames)
6423 {
6424 case 2:
6425 267131 tiledir_small(dir,ndir==4);
6426 267131 break;
6427
6428 case 3:
6429 tiledir_three(dir);
6430 break;
6431
6432 case 4:
6433 19872069 tiledir(dir,ndir==4);
6434 19872069 break;
6435 20139200 }
6436
6437
2/2
✓ Branch 0 taken 10866215 times.
✓ Branch 1 taken 9457322 times.
20323537 if(family==eeWALK)
6438
6/6
✓ Branch 0 taken 10803916 times.
✓ Branch 1 taken 62299 times.
✓ Branch 2 taken 8200379 times.
✓ Branch 3 taken 2665836 times.
✓ Branch 4 taken 2649784 times.
✓ Branch 5 taken 16052 times.
10866215 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6439 else
6440 9457322 tile+=f4;
6441 20323537 }
6442 20323537 return b;
6443 }
6444
6445 void enemy::tiledir_three(int32_t ndir)
6446 {
6447 if ( !do_animation ) return;
6448 flip=0;
6449
6450 switch(ndir)
6451 {
6452 case right:
6453 tile+=3;
6454 [[fallthrough]];
6455
6456 case left:
6457 tile+=3;
6458 [[fallthrough]];
6459
6460 case down:
6461 tile+=3;
6462 [[fallthrough]];
6463
6464 case up:
6465 break;
6466 }
6467 }
6468
6469 267131 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6470 {
6471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267131 times.
267131 if ( !do_animation ) return;
6472 267131 flip=0;
6473
6474
8/9
✓ Branch 0 taken 53829 times.
✓ Branch 1 taken 54679 times.
✓ Branch 2 taken 67727 times.
✓ Branch 3 taken 71182 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
267131 switch(ndir)
6475 {
6476 case 8:
6477 case up:
6478 53829 break;
6479
6480 case 12:
6481 case down:
6482 54679 tile+=2;
6483 54679 break;
6484
6485 case 14:
6486 case left:
6487 67727 tile+=4;
6488 67727 break;
6489
6490 case 10:
6491 case right:
6492 71182 tile+=6;
6493 71182 break;
6494
6495 case 9:
6496 case r_up:
6497
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6498 5706 break;
6499
6500 tile+=10;
6501 break;
6502
6503 case 11:
6504 case r_down:
6505
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6506 5154 tile+=2;
6507 else
6508 tile+=14;
6509
6510 5154 break;
6511
6512 case 13:
6513 case l_down:
6514
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6515 4872 tile+=2;
6516 else
6517 tile+=12;
6518
6519 4872 break;
6520
6521 case 15:
6522 case l_up:
6523
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6524 3982 break;
6525
6526 tile+=8;
6527 break;
6528
6529 default:
6530 //dir=(zc_oldrand()*100)%8;
6531 //tiledir_small(dir);
6532 // flip=zc_oldrand()&3;
6533 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6534 break;
6535 }
6536 267131 }
6537
6538 23204817 void enemy::tiledir(int32_t ndir, bool fourdir)
6539 {
6540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23204817 times.
23204817 if ( !do_animation ) return;
6541 23204817 flip=0;
6542
6543
9/9
✓ Branch 0 taken 4509491 times.
✓ Branch 1 taken 4163411 times.
✓ Branch 2 taken 5445014 times.
✓ Branch 3 taken 5198072 times.
✓ Branch 4 taken 834140 times.
✓ Branch 5 taken 1027612 times.
✓ Branch 6 taken 1106457 times.
✓ Branch 7 taken 852481 times.
✓ Branch 8 taken 68139 times.
23204817 switch(ndir)
6544 {
6545 case 8:
6546 case up:
6547 4509491 break;
6548
6549 case 12:
6550 case down:
6551 4163411 tile+=4;
6552 4163411 break;
6553
6554 case 14:
6555 case left:
6556 5445014 tile+=8;
6557 5445014 break;
6558
6559 case 10:
6560 case right:
6561 5198072 tile+=12;
6562 5198072 break;
6563
6564 case 9:
6565 case r_up:
6566
2/2
✓ Branch 0 taken 89257 times.
✓ Branch 1 taken 744883 times.
834140 if(fourdir)
6567 89257 break;
6568 else
6569 744883 tile+=24;
6570
6571 744883 break;
6572
6573 case 11:
6574 case r_down:
6575
2/2
✓ Branch 0 taken 102657 times.
✓ Branch 1 taken 924955 times.
1027612 if(fourdir)
6576 102657 tile+=4;
6577 else
6578 924955 tile+=32;
6579
6580 1027612 break;
6581
6582 case 13:
6583 case l_down:
6584
2/2
✓ Branch 0 taken 106171 times.
✓ Branch 1 taken 1000286 times.
1106457 if(fourdir)
6585 106171 tile+=4;
6586 else
6587 1000286 tile+=28;
6588
6589 1106457 break;
6590
6591 case 15:
6592 case l_up:
6593
2/2
✓ Branch 0 taken 82882 times.
✓ Branch 1 taken 769599 times.
852481 if(fourdir)
6594 82882 break;
6595 else
6596 769599 tile+=20;
6597
6598 769599 break;
6599
6600 default:
6601 //dir=(zc_oldrand()*100)%8;
6602 //tiledir(dir);
6603 // flip=zc_oldrand()&3;
6604 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6605 68139 break;
6606 }
6607 23204817 }
6608
6609 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6610 {
6611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if ( !do_animation ) return;
6612 3868 flip=0;
6613
6614
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6615 {
6616 case 8:
6617 case up:
6618 297 break;
6619
6620 case 12:
6621 case down:
6622 tile+=8;
6623 break;
6624
6625 case 14:
6626 case left:
6627 195 tile+=40;
6628 195 break;
6629
6630 case 10:
6631 case right:
6632 179 tile+=48;
6633 179 break;
6634
6635 case 9:
6636 case r_up:
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6638 break;
6639
6640 306 tile+=88;
6641 306 break;
6642
6643 case 11:
6644 case r_down:
6645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6646 tile+=8;
6647 else
6648 1235 tile+=128;
6649
6650 1235 break;
6651
6652 case 13:
6653 case l_down:
6654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6655 tile+=8;
6656 else
6657 1324 tile+=120;
6658
6659 1324 break;
6660
6661 case 15:
6662 case l_up:
6663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6664 break;
6665
6666 332 tile+=80;
6667 332 break;
6668
6669 default:
6670 //dir=(zc_oldrand()*100)%8;
6671 //tiledir_big(dir);
6672 // flip=zc_oldrand()&3;
6673 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6674 break;
6675 }
6676 3868 }
6677
6678 40047240 void enemy::update_enemy_frame()
6679 {
6680
4/4
✓ Branch 0 taken 40044865 times.
✓ Branch 1 taken 2375 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 40044858 times.
40047240 if(fallclk||drownclk) return;
6681
1/2
✓ Branch 0 taken 40044858 times.
✗ Branch 1 not taken.
40044858 if (!do_animation)
6682 return;
6683
6684
4/4
✓ Branch 0 taken 1550526 times.
✓ Branch 1 taken 38494332 times.
✓ Branch 2 taken 1548519 times.
✓ Branch 3 taken 2007 times.
40044858 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6685
6686
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
40044858 if(get_qr(qr_ANONE_NOANIM)
6687
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40044858 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40044858 && anim == aNONE && family != eeGUY)
6688 return;
6689
2/2
✓ Branch 0 taken 371376 times.
✓ Branch 1 taken 39673482 times.
40044858 int32_t newfrate = zc_max(frate,4);
6690 40044858 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6691 40044858 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6692
2/2
✓ Branch 0 taken 30165053 times.
✓ Branch 1 taken 9879805 times.
40044858 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6693 40044858 tile = o_tile;
6694 40044858 int32_t basetile = o_tile;
6695 40044858 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6696 40044858 bool ignore_extend = false;
6697
35/40
✓ Branch 0 taken 215946 times.
✓ Branch 1 taken 8628 times.
✓ Branch 2 taken 209083 times.
✓ Branch 3 taken 1755010 times.
✓ Branch 4 taken 363745 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 126198 times.
✓ Branch 7 taken 366633 times.
✓ Branch 8 taken 836734 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 5041951 times.
✓ Branch 12 taken 69324 times.
✓ Branch 13 taken 53456 times.
✓ Branch 14 taken 38833 times.
✓ Branch 15 taken 455374 times.
✓ Branch 16 taken 1525813 times.
✓ Branch 17 taken 184337 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 128880 times.
✓ Branch 20 taken 221637 times.
✓ Branch 21 taken 693272 times.
✓ Branch 22 taken 1681063 times.
✓ Branch 23 taken 1134909 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 267131 times.
✓ Branch 26 taken 4135763 times.
✓ Branch 27 taken 7515986 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 578575 times.
✓ Branch 30 taken 1178979 times.
✓ Branch 31 taken 867610 times.
✓ Branch 32 taken 219096 times.
✓ Branch 33 taken 1818304 times.
✓ Branch 34 taken 133344 times.
✓ Branch 35 taken 1433 times.
✓ Branch 36 taken 7018408 times.
✓ Branch 37 taken 747030 times.
✓ Branch 38 taken 276997 times.
✓ Branch 39 taken 171508 times.
40044858 switch(anim)
6698 {
6699
6700 case aDONGO:
6701 {
6702 69324 int32_t fr = stunclk>0 ? 16 : 8;
6703
6704
6/6
✓ Branch 0 taken 67426 times.
✓ Branch 1 taken 1898 times.
✓ Branch 2 taken 6720 times.
✓ Branch 3 taken 60706 times.
✓ Branch 4 taken 2240 times.
✓ Branch 5 taken 4480 times.
69324 if(!dying && clk2>0 && clk2<=64)
6705 {
6706 // bloated
6707
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 960 times.
✓ Branch 3 taken 1664 times.
✓ Branch 4 taken 896 times.
4480 switch(dir)
6708 {
6709 case up:
6710 960 tile+=9;
6711 960 flip=0;
6712 960 xofs=0;
6713 960 dummy_int[1]=0; //no additional tiles
6714 960 break;
6715
6716 case down:
6717 960 tile+=7;
6718 960 flip=0;
6719 960 xofs=0;
6720 960 dummy_int[1]=0; //no additional tiles
6721 960 break;
6722
6723 case left:
6724 1664 flip=1;
6725 1664 tile+=4;
6726 1664 xofs=16;
6727 1664 dummy_int[1]=1; //second tile is next tile
6728 1664 break;
6729
6730 case right:
6731 896 flip=0;
6732 896 tile+=5;
6733 896 xofs=16;
6734 896 dummy_int[1]=-1; //second tile is previous tile
6735 896 break;
6736 }
6737 4480 }
6738
4/4
✓ Branch 0 taken 1898 times.
✓ Branch 1 taken 62946 times.
✓ Branch 2 taken 781 times.
✓ Branch 3 taken 1117 times.
64844 else if(!dying || clk2>19)
6739 {
6740 // normal
6741
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 13652 times.
✓ Branch 2 taken 15374 times.
✓ Branch 3 taken 19615 times.
✓ Branch 4 taken 15086 times.
63727 switch(dir)
6742 {
6743 case up:
6744 13652 tile+=8;
6745 13652 flip=(clk&fr)?1:0;
6746 13652 xofs=0;
6747 13652 dummy_int[1]=0; //no additional tiles
6748 13652 break;
6749
6750 case down:
6751 15374 tile+=6;
6752 15374 flip=(clk&fr)?1:0;
6753 15374 xofs=0;
6754 15374 dummy_int[1]=0; //no additional tiles
6755 15374 break;
6756
6757 case left:
6758 19615 flip=1;
6759 19615 tile+=(clk&fr)?2:0;
6760 19615 xofs=16;
6761 19615 dummy_int[1]=1; //second tile is next tile
6762 19615 break;
6763
6764 case right:
6765 15086 flip=0;
6766 15086 tile+=(clk&fr)?3:1;
6767 15086 xofs=16;
6768 15086 dummy_int[1]=-1; //second tile is next tile
6769 15086 break;
6770 }
6771 63727 }
6772 }
6773 69324 break;
6774
6775 case aNEWDONGO:
6776 {
6777 53456 int32_t fr4=0;
6778
6779
6/6
✓ Branch 0 taken 51564 times.
✓ Branch 1 taken 1892 times.
✓ Branch 2 taken 4128 times.
✓ Branch 3 taken 47436 times.
✓ Branch 4 taken 1376 times.
✓ Branch 5 taken 2752 times.
53456 if(!dying && clk2>0 && clk2<=64)
6780 {
6781 // bloated
6782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2752 times.
2752 if(clk2>=0)
6783 {
6784 2752 fr4=3;
6785 2752 }
6786
6787
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 2107 times.
2752 if(clk2>=16)
6788 {
6789 2107 fr4=2;
6790 2107 }
6791
6792
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 1419 times.
2752 if(clk2>=32)
6793 {
6794 1419 fr4=1;
6795 1419 }
6796
6797
2/2
✓ Branch 0 taken 2021 times.
✓ Branch 1 taken 731 times.
2752 if(clk2>=48)
6798 {
6799 731 fr4=0;
6800 731 }
6801
6802
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1216 times.
2752 switch(dir)
6803 {
6804 case up:
6805 256 xofs=0;
6806 256 tile+=8+fr4;
6807 256 dummy_int[1]=0; //no additional tiles
6808 256 break;
6809
6810 case down:
6811 576 xofs=0;
6812 576 tile+=12+fr4;
6813 576 dummy_int[1]=0; //no additional tiles
6814 576 break;
6815
6816 case left:
6817 704 tile+=29+(2*fr4);
6818 704 xofs=16;
6819 704 dummy_int[1]=-1; //second tile is previous tile
6820 704 break;
6821
6822 case right:
6823 1216 tile+=49+(2*fr4);
6824 1216 xofs=16;
6825 1216 dummy_int[1]=-1; //second tile is previous tile
6826 1216 break;
6827 }
6828 2752 }
6829
4/4
✓ Branch 0 taken 1892 times.
✓ Branch 1 taken 48812 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 898 times.
50704 else if(!dying || clk2>19)
6830 {
6831 // normal
6832
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9234 times.
✓ Branch 2 taken 9871 times.
✓ Branch 3 taken 15025 times.
✓ Branch 4 taken 15676 times.
49806 switch(dir)
6833 {
6834 case up:
6835 9234 xofs=0;
6836 9234 tile+=((clk&12)>>2);
6837 9234 dummy_int[1]=0; //no additional tiles
6838 9234 break;
6839
6840 case down:
6841 9871 xofs=0;
6842 9871 tile+=4+((clk&12)>>2);
6843 9871 dummy_int[1]=0; //no additional tiles
6844 9871 break;
6845
6846 case left:
6847 15025 tile+=21+((clk&12)>>1);
6848 15025 xofs=16;
6849 15025 dummy_int[1]=-1; //second tile is previous tile
6850 15025 break;
6851
6852 case right:
6853 15676 flip=0;
6854 15676 tile+=41+((clk&12)>>1);
6855 15676 xofs=16;
6856 15676 dummy_int[1]=-1; //second tile is previous tile
6857 15676 break;
6858 }
6859 49806 }
6860 }
6861 53456 break;
6862
6863 case aDONGOBS:
6864 {
6865 38833 int32_t fr4=0;
6866
6867
6/6
✓ Branch 0 taken 37675 times.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 4032 times.
✓ Branch 3 taken 33643 times.
✓ Branch 4 taken 1344 times.
✓ Branch 5 taken 2688 times.
38833 if(!dying && clk2>0 && clk2<=64)
6868 {
6869 // bloated
6870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2688 times.
2688 if(clk2>=0)
6871 {
6872 2688 fr4=3;
6873 2688 }
6874
6875
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2058 times.
2688 if(clk2>=16)
6876 {
6877 2058 fr4=2;
6878 2058 }
6879
6880
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 1386 times.
2688 if(clk2>=32)
6881 {
6882 1386 fr4=1;
6883 1386 }
6884
6885
2/2
✓ Branch 0 taken 1974 times.
✓ Branch 1 taken 714 times.
2688 if(clk2>=48)
6886 {
6887 714 fr4=0;
6888 714 }
6889
6890
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 384 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1024 times.
2688 switch(dir)
6891 {
6892 case up:
6893 256 tile+=28+fr4;
6894 256 yofs+=8;
6895 256 dummy_int[1]=-20; //second tile change
6896 256 dummy_int[2]=0; //new xofs change
6897 256 dummy_int[3]=-16; //new xofs change
6898 256 break;
6899
6900 case down:
6901 384 tile+=12+fr4;
6902 384 yofs-=8;
6903 384 dummy_int[1]=20; //second tile change
6904 384 dummy_int[2]=0; //new xofs change
6905 384 dummy_int[3]=16; //new xofs change
6906 384 break;
6907
6908 case left:
6909 1024 tile+=49+(2*fr4);
6910 1024 xofs+=8;
6911 1024 dummy_int[1]=-1; //second tile change
6912 1024 dummy_int[2]=-16; //new xofs change
6913 1024 dummy_int[3]=0; //new xofs change
6914 1024 break;
6915
6916 case right:
6917 1024 tile+=69+(2*fr4);
6918 1024 xofs+=8;
6919 1024 dummy_int[1]=-1; //second tile change
6920 1024 dummy_int[2]=-16; //new xofs change
6921 1024 dummy_int[3]=0; //new xofs change
6922 1024 break;
6923 }
6924 2688 }
6925
4/4
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 34987 times.
✓ Branch 2 taken 497 times.
✓ Branch 3 taken 661 times.
36145 else if(!dying || clk2>19)
6926 {
6927 // normal
6928
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7136 times.
✓ Branch 2 taken 6672 times.
✓ Branch 3 taken 11075 times.
✓ Branch 4 taken 10601 times.
35484 switch(dir)
6929 {
6930 case up:
6931 7136 tile+=20+((clk&24)>>3);
6932 7136 yofs+=8;
6933 7136 dummy_int[1]=-20; //second tile change
6934 7136 dummy_int[2]=0; //new xofs change
6935 7136 dummy_int[3]=-16; //new xofs change
6936 7136 break;
6937
6938 case down:
6939 6672 tile+=4+((clk&24)>>3);
6940 6672 yofs-=8;
6941 6672 dummy_int[1]=20; //second tile change
6942 6672 dummy_int[2]=0; //new xofs change
6943 6672 dummy_int[3]=16; //new xofs change
6944 6672 break;
6945
6946 case left:
6947 11075 xofs=-8;
6948 11075 tile+=40+((clk&24)>>2);
6949 11075 dummy_int[1]=1; //second tile change
6950 11075 dummy_int[2]=16; //new xofs change
6951 11075 dummy_int[3]=0; //new xofs change
6952 11075 break;
6953
6954 case right:
6955 10601 tile+=60+((clk&24)>>2);
6956 10601 xofs=-8;
6957 10601 dummy_int[1]=1; //second tile change
6958 10601 dummy_int[2]=16; //new xofs change
6959 10601 dummy_int[3]=0; //new xofs change
6960 10601 break;
6961 }
6962 35484 }
6963 }
6964 38833 break;
6965
6966 case aWIZZ:
6967 {
6968 // if(d->misc1)
6969
2/2
✓ Branch 0 taken 182184 times.
✓ Branch 1 taken 273190 times.
455374 if(dmisc1)
6970 {
6971
2/2
✓ Branch 0 taken 91057 times.
✓ Branch 1 taken 91127 times.
182184 if(clk&8)
6972 {
6973 91127 ++tile;
6974 91127 }
6975 182184 }
6976 else
6977 {
6978
2/2
✓ Branch 0 taken 136701 times.
✓ Branch 1 taken 136489 times.
273190 if(frame&4)
6979 {
6980 136489 ++tile;
6981 136489 }
6982 }
6983
6984
4/4
✓ Branch 0 taken 76094 times.
✓ Branch 1 taken 157108 times.
✓ Branch 2 taken 145581 times.
✓ Branch 3 taken 76591 times.
455374 switch(dir)
6985 {
6986 case 9:
6987 case 15:
6988 case up:
6989 76094 tile+=2;
6990 76094 break;
6991
6992 case down:
6993 76591 break;
6994
6995 case 13:
6996 case left:
6997 157108 flip=1;
6998 157108 break;
6999
7000 default:
7001 145581 flip=0;
7002 145581 break;
7003 }
7004 }
7005 455374 break;
7006
7007 case aNEWWIZZ:
7008 {
7009 1525813 tiledir(dir,true);
7010
7011 // if(d->misc1) //walking wizzrobe
7012
2/2
✓ Branch 0 taken 742424 times.
✓ Branch 1 taken 783389 times.
1525813 if(dmisc1) //walking wizzrobe
7013 {
7014
2/2
✓ Branch 0 taken 373321 times.
✓ Branch 1 taken 369103 times.
742424 if(clk&8)
7015 {
7016 369103 tile+=2;
7017 369103 }
7018
7019
2/2
✓ Branch 0 taken 372085 times.
✓ Branch 1 taken 370339 times.
742424 if(clk&4)
7020 {
7021 370339 tile+=1;
7022 370339 }
7023
7024
2/4
✓ Branch 0 taken 742424 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 742424 times.
742424 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7025 {
7026
2/2
✓ Branch 0 taken 663262 times.
✓ Branch 1 taken 79162 times.
742424 if(dummy_int[1]>0)
7027 {
7028 79162 tile+=40;
7029 79162 }
7030 742424 }
7031 742424 }
7032 else
7033 {
7034
4/4
✓ Branch 0 taken 716244 times.
✓ Branch 1 taken 67145 times.
✓ Branch 2 taken 168827 times.
✓ Branch 3 taken 547417 times.
783389 if(dummy_bool[1]||dummy_bool[2])
7035 {
7036 235972 tile+=20;
7037
7038
2/2
✓ Branch 0 taken 67136 times.
✓ Branch 1 taken 168836 times.
235972 if(dummy_bool[2])
7039 {
7040 168836 tile+=20;
7041 168836 }
7042 235972 }
7043
7044 783389 tile+=((frame>>1)&3);
7045 }
7046 }
7047 1525813 break;
7048
7049 case a3FRM:
7050 {
7051
2/2
✓ Branch 0 taken 43688 times.
✓ Branch 1 taken 140649 times.
184337 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7052 }
7053 184337 break;
7054
7055 case a3FRM4DIR:
7056 {
7057 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7058 }
7059 break;
7060
7061 case aVIRE:
7062 {
7063
2/2
✓ Branch 0 taken 99588 times.
✓ Branch 1 taken 29292 times.
128880 if(dir==up)
7064 {
7065 29292 tile+=2;
7066 29292 }
7067
7068 128880 tile+=fx;
7069 }
7070 128880 break;
7071
7072 case aROPE:
7073 {
7074 215946 tile+=(1-fx);
7075 215946 flip = dir==left ? 1:0;
7076 }
7077 215946 break;
7078
7079 case aZORA:
7080 {
7081 int32_t dl;
7082
7083
2/2
✓ Branch 0 taken 46739 times.
✓ Branch 1 taken 174898 times.
221637 if(clk<36)
7084 {
7085 46739 dl=clk+5;
7086 46739 goto waves2;
7087 }
7088
7089
2/2
✓ Branch 0 taken 82440 times.
✓ Branch 1 taken 92458 times.
174898 if(clk<36+66)
7090
2/2
✓ Branch 0 taken 50715 times.
✓ Branch 1 taken 31725 times.
82440 tile=(dir==up)?o_tile+1:o_tile;
7091 else
7092 {
7093 92458 dl=clk-36-66;
7094 waves2:
7095 139197 tile=((dl/11)&1)+s_tile;
7096 139197 basetile = s_tile;
7097 }
7098 }
7099 221637 break;
7100
7101 case aNEWZORA:
7102 {
7103 693272 f4=(clk/16)%4;
7104
7105 693272 tiledir(dir,true);
7106 int32_t dl;
7107
7108
4/4
✓ Branch 0 taken 489980 times.
✓ Branch 1 taken 203292 times.
✓ Branch 2 taken 251304 times.
✓ Branch 3 taken 238676 times.
693272 if((clk>35)&&(clk<36+67)) //surfaced
7109 {
7110
4/4
✓ Branch 0 taken 204043 times.
✓ Branch 1 taken 34633 times.
✓ Branch 2 taken 29458 times.
✓ Branch 3 taken 174585 times.
238676 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7111 {
7112 174585 tile+=80;
7113 174585 } //mouth closed
7114 else
7115 {
7116 64091 tile+=40;
7117 }
7118
7119 238676 tile+=f4;
7120 238676 }
7121 else
7122 {
7123
2/2
✓ Branch 0 taken 203292 times.
✓ Branch 1 taken 251304 times.
454596 if(clk<36)
7124 {
7125 203292 dl=clk+5;
7126 203292 }
7127 else
7128 {
7129 251304 dl=clk-36-66;
7130 }
7131
7132 454596 tile+=((dl/5)&3);
7133 }
7134 }
7135 693272 break;
7136
7137 case a4FRM4EYE:
7138 case a2FRM4EYE:
7139 case a4FRM8EYE:
7140 case a4FRM8EYEB: //big version
7141 case a4FRM4EYEB:
7142 {
7143 836734 tilerows = 2;
7144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakex = x + 8*(zc_max(1,txsz)-1);
7145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 836734 times.
836734 int fakey = y + 8*(zc_max(1,tysz)-1);
7146 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7147 836734 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7148 836734 int32_t lookat=zc_oldrand()&15;
7149
7150
4/4
✓ Branch 0 taken 272091 times.
✓ Branch 1 taken 564643 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 210774 times.
836734 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7151 {
7152 210774 lookat=l_down;
7153 210774 }
7154
4/4
✓ Branch 0 taken 288167 times.
✓ Branch 1 taken 337793 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 226850 times.
625960 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7155 {
7156 226850 lookat=down;
7157 226850 }
7158
4/4
✓ Branch 0 taken 170154 times.
✓ Branch 1 taken 228956 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 108837 times.
399110 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7159 {
7160 108837 lookat=r_down;
7161 108837 }
7162
4/4
✓ Branch 0 taken 131712 times.
✓ Branch 1 taken 158561 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 70395 times.
290273 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7163 {
7164 70395 lookat=right;
7165 70395 }
7166
4/4
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 123494 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 35067 times.
219878 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7167 {
7168 35067 lookat=r_up;
7169 35067 }
7170
4/4
✓ Branch 0 taken 86753 times.
✓ Branch 1 taken 98058 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 25436 times.
184811 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7171 {
7172 25436 lookat=up;
7173 25436 }
7174
4/4
✓ Branch 0 taken 98120 times.
✓ Branch 1 taken 61255 times.
✓ Branch 2 taken 61317 times.
✓ Branch 3 taken 36803 times.
159375 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7175 {
7176 36803 lookat=l_up;
7177 36803 }
7178 else
7179 {
7180 122572 lookat=left;
7181 }
7182
7183 836734 int32_t dir2 = dir;
7184 836734 dir = lookat;
7185
3/6
✓ Branch 0 taken 836734 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 836734 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 836734 times.
836734 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7186 else
7187 {
7188 tiledir_big(dir,(anim == a4FRM4EYEB));
7189 tile+=2*f4;
7190 ignore_extend = true;
7191 }
7192 836734 dir = dir2;
7193 }
7194 836734 break;
7195
7196 case aFLIP:
7197 {
7198 1681063 flip = f2&1;
7199 }
7200 1681063 break;
7201
7202 case a2FRM:
7203 {
7204 1134909 tile += (1-f2);
7205 }
7206 1134909 break;
7207
7208 case a2FRMB:
7209 {
7210 tile+= 2*(1-f2);
7211 ignore_extend = true;
7212 }
7213 break;
7214
7215 case a2FRM4DIR:
7216 {
7217 267131 basetile = n_frame_n_dir(2, 4, f2&1);
7218 }
7219 267131 break;
7220
7221 case a4FRM4DIRF:
7222 {
7223 4135763 basetile = n_frame_n_dir(4,4,f4);
7224
7225
2/2
✓ Branch 0 taken 2734430 times.
✓ Branch 1 taken 1401333 times.
4135763 if(clk2>0) //stopped to fire
7226 {
7227 1401333 tile+=20;
7228
7229
2/2
✓ Branch 0 taken 698495 times.
✓ Branch 1 taken 702838 times.
1401333 if(clk2<17) //firing
7230 {
7231 702838 tile+=20;
7232 702838 }
7233 1401333 }
7234 }
7235 4135763 break;
7236
7237 case a4FRM4DIR:
7238 {
7239 7515986 basetile = n_frame_n_dir(4,4,f4);
7240 }
7241 7515986 break;
7242
7243 case a4FRM8DIRF:
7244 {
7245 tilerows = 2;
7246 basetile = n_frame_n_dir(4,8,f4);
7247
7248 if(clk2>0) //stopped to fire
7249 {
7250 tile+=40;
7251
7252 if(clk2<17) //firing
7253 {
7254 tile+=40;
7255 }
7256 }
7257 }
7258 break;
7259
7260 case a4FRM8DIRB:
7261 case a4FRM8DIRFB:
7262 {
7263 3868 tilerows = 2;
7264 3868 tiledir_big(dir,false);
7265 3868 tile+=2*f4;
7266
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7267 {
7268 tile+=80;
7269
7270 if(clk2<17) //firing
7271 {
7272 tile+=80;
7273 }
7274 }
7275 3868 ignore_extend = true;
7276 }
7277 3868 break;
7278
7279 case a4FRM4DIRB:
7280 case a4FRM4DIRFB:
7281 {
7282 tilerows = 2;
7283 tiledir_big(dir,true);
7284 tile+=2*f4;
7285 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7286 {
7287 tile+=40;
7288
7289 if(clk2<17) //firing
7290 {
7291 tile+=40;
7292 }
7293 }
7294 ignore_extend = true;
7295 }
7296 break;
7297
7298 case aOCTO:
7299 {
7300
5/5
✓ Branch 0 taken 4152 times.
✓ Branch 1 taken 121259 times.
✓ Branch 2 taken 132979 times.
✓ Branch 3 taken 164253 times.
✓ Branch 4 taken 155932 times.
578575 switch(dir)
7301 {
7302 case up:
7303 121259 flip = 2;
7304 121259 break;
7305
7306 case down:
7307 132979 flip = 0;
7308 132979 break;
7309
7310 case left:
7311 164253 flip = 0;
7312 164253 tile += 2;
7313 164253 break;
7314
7315 case right:
7316 155932 flip = 1;
7317 155932 tile += 2;
7318 155932 break;
7319 }
7320
7321 578575 tile+=f2;
7322 }
7323 578575 break;
7324
7325 case aWALK:
7326 {
7327
5/5
✓ Branch 0 taken 5614 times.
✓ Branch 1 taken 248704 times.
✓ Branch 2 taken 267165 times.
✓ Branch 3 taken 331694 times.
✓ Branch 4 taken 325802 times.
1178979 switch(dir)
7328 {
7329 case up:
7330 248704 tile+=3;
7331 248704 flip = f2;
7332 248704 break;
7333
7334 case down:
7335 267165 tile+=2;
7336 267165 flip = f2;
7337 267165 break;
7338
7339 case left:
7340 331694 flip=1;
7341 331694 tile += f2;
7342 331694 break;
7343
7344 case right:
7345 325802 flip=0;
7346 325802 tile += f2;
7347 325802 break;
7348 }
7349 }
7350 1178979 break;
7351
7352 case aDWALK:
7353 {
7354
3/4
✓ Branch 0 taken 92330 times.
✓ Branch 1 taken 775280 times.
✓ Branch 2 taken 92330 times.
✗ Branch 3 not taken.
867610 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7355 {
7356 tile=s_tile;
7357 basetile = s_tile;
7358 }
7359
7360
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 175759 times.
✓ Branch 2 taken 183174 times.
✓ Branch 3 taken 256607 times.
✓ Branch 4 taken 252070 times.
867610 switch(dir)
7361 {
7362 case up:
7363 175759 tile+=2;
7364 175759 flip=f2;
7365 175759 break;
7366
7367 case down:
7368 183174 flip=0;
7369 183174 tile+=(1-f2);
7370 183174 break;
7371
7372 case left:
7373 256607 flip=1;
7374 256607 tile+=(3+f2);
7375 256607 break;
7376
7377 case right:
7378 252070 flip=0;
7379 252070 tile+=(3+f2);
7380 252070 break;
7381 }
7382 }
7383 867610 break;
7384
7385 case aTEK:
7386 {
7387
2/2
✓ Branch 0 taken 139976 times.
✓ Branch 1 taken 79120 times.
219096 if(misc==0)
7388 {
7389 79120 tile += f2;
7390 79120 }
7391
2/2
✓ Branch 0 taken 73149 times.
✓ Branch 1 taken 66827 times.
139976 else if(misc!=1)
7392 {
7393 66827 ++tile;
7394 66827 }
7395 }
7396 219096 break;
7397
7398 case aNEWTEK:
7399 {
7400
2/2
✓ Branch 0 taken 475246 times.
✓ Branch 1 taken 1343058 times.
1818304 if(step<0) //up
7401 {
7402
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 235369 times.
✓ Branch 2 taken 239877 times.
475246 switch(clk3)
7403 {
7404 case left:
7405 235369 flip=0;
7406 235369 tile+=20;
7407 235369 break;
7408
7409 case right:
7410 239877 flip=0;
7411 239877 tile+=24;
7412 239877 break;
7413 }
7414 475246 }
7415
2/2
✓ Branch 0 taken 54749 times.
✓ Branch 1 taken 1288309 times.
1343058 else if(step==0)
7416 {
7417
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 40566 times.
✓ Branch 2 taken 14183 times.
54749 switch(clk3)
7418 {
7419 case left:
7420 40566 flip=0;
7421 40566 tile+=8;
7422 40566 break;
7423
7424 case right:
7425 14183 flip=0;
7426 14183 tile+=12;
7427 14183 break;
7428 }
7429 54749 } //down
7430 else
7431 {
7432
3/3
✓ Branch 0 taken 109149 times.
✓ Branch 1 taken 593340 times.
✓ Branch 2 taken 585820 times.
1288309 switch(clk3)
7433 {
7434 case left:
7435 593340 flip=0;
7436 593340 tile+=28;
7437 593340 break;
7438
7439 case right:
7440 585820 flip=0;
7441 585820 tile+=32;
7442 585820 break;
7443 }
7444 }
7445
7446
2/2
✓ Branch 0 taken 1238755 times.
✓ Branch 1 taken 579549 times.
1818304 if(misc==0)
7447 {
7448 579549 tile+=f4;
7449 579549 }
7450
2/2
✓ Branch 0 taken 582085 times.
✓ Branch 1 taken 656670 times.
1238755 else if(misc!=1)
7451 {
7452 656670 tile+=2;
7453 656670 }
7454 }
7455 1818304 break;
7456
7457 case aARMOS:
7458 {
7459
2/2
✓ Branch 0 taken 3227 times.
✓ Branch 1 taken 5401 times.
8628 if(!fading)
7460 {
7461 5401 tile += fx;
7462
7463
2/2
✓ Branch 0 taken 4204 times.
✓ Branch 1 taken 1197 times.
5401 if(dir==up)
7464 1197 tile += 2;
7465 5401 }
7466 }
7467 8628 break;
7468
7469 case aARMOS4:
7470 {
7471
5/5
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 29165 times.
✓ Branch 2 taken 92624 times.
✓ Branch 3 taken 43654 times.
✓ Branch 4 taken 43190 times.
209083 switch(dir)
7472 {
7473 case up:
7474 29165 flip=0;
7475 29165 break;
7476
7477 case down:
7478 92624 flip=0;
7479 92624 tile+=4;
7480 92624 break;
7481
7482 case left:
7483 43654 flip=0;
7484 43654 tile+=8;
7485 43654 break;
7486
7487 case right:
7488 43190 flip=0;
7489 43190 tile+=12;
7490 43190 break;
7491 }
7492
7493
2/2
✓ Branch 0 taken 63155 times.
✓ Branch 1 taken 145928 times.
209083 if(!fading)
7494 {
7495 145928 tile+=f4;
7496 145928 }
7497 }
7498 209083 break;
7499
7500 case aGHINI:
7501 {
7502
4/4
✓ Branch 0 taken 28037 times.
✓ Branch 1 taken 32092 times.
✓ Branch 2 taken 72763 times.
✓ Branch 3 taken 452 times.
133344 switch(dir)
7503 {
7504 case 8:
7505 case 9:
7506 case up:
7507 28037 ++tile;
7508 28037 flip=0;
7509 28037 break;
7510
7511 case 15:
7512 452 ++tile;
7513 452 flip=1;
7514 452 break;
7515
7516 case 10:
7517 case 11:
7518 case right:
7519 32092 flip=1;
7520 32092 break;
7521
7522 default:
7523 72763 flip=0;
7524 72763 break;
7525 }
7526 }
7527 133344 break;
7528
7529 case a2FRMPOS:
7530 {
7531 1755010 tile+=posframe;
7532 }
7533 1755010 break;
7534
7535 case a4FRMPOS4DIR:
7536 {
7537 363745 basetile = n_frame_n_dir(4,4,0);
7538 // tile+=f2;
7539 363745 tile+=posframe;
7540 }
7541 363745 break;
7542
7543 case a4FRMPOS4DIRF:
7544 {
7545 1433 basetile = n_frame_n_dir(4,4,0);
7546
7547
2/2
✓ Branch 0 taken 1236 times.
✓ Branch 1 taken 197 times.
1433 if(clk2>0) //stopped to fire
7548 {
7549 197 tile+=20;
7550
7551
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 64 times.
197 if(clk2<17) //firing
7552 {
7553 64 tile+=20;
7554 64 }
7555 197 }
7556
7557 // tile+=f2;
7558 1433 tile+=posframe;
7559 }
7560 1433 break;
7561
7562 case a4FRMPOS8DIR:
7563 {
7564 7018408 tilerows = 2;
7565 7018408 int32_t n = tile;
7566 7018408 basetile = n_frame_n_dir(4,8,0);
7567 // tile+=f2;
7568 7018408 tile+=posframe;
7569 }
7570 7018408 break;
7571
7572 case a4FRMPOS8DIRF:
7573 {
7574 tilerows = 2;
7575 basetile = n_frame_n_dir(4,8,0);
7576
7577 if(clk2>0) //stopped to fire
7578 {
7579 tile+=40;
7580
7581 if(clk2<17) //firing
7582 {
7583 tile+=40;
7584 }
7585 }
7586
7587 tile+=posframe;
7588 }
7589 break;
7590
7591 case aNEWLEV:
7592 {
7593 747030 tiledir(dir,true);
7594
7595
4/5
✓ Branch 0 taken 258994 times.
✓ Branch 1 taken 115368 times.
✓ Branch 2 taken 48980 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 323688 times.
747030 switch(misc)
7596 {
7597 case -1:
7598 case 0:
7599 258994 return;
7600
7601 case 1:
7602
7603 // case 5: cs = d->misc2; break;
7604 case 5:
7605 115368 cs = dmisc2;
7606 115368 break;
7607
7608 case 2:
7609 case 4:
7610 48980 tile += 20;
7611 48980 break;
7612
7613 case 3:
7614 323688 tile += 40;
7615 323688 break;
7616 }
7617
7618 488036 tile+=f4;
7619 }
7620 488036 break;
7621
7622 case aLEV:
7623 {
7624 276997 f4 = ((clk/5)&1);
7625
7626
4/5
✓ Branch 0 taken 127945 times.
✓ Branch 1 taken 33336 times.
✓ Branch 2 taken 14658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101058 times.
276997 switch(misc)
7627 {
7628 case -1:
7629 case 0:
7630 127945 return;
7631
7632 case 1:
7633
7634 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7635 case 5:
7636 33336 tile += (f2) ? 1 : 0;
7637 33336 cs = dmisc2;
7638 33336 break;
7639
7640 case 2:
7641 case 4:
7642 14658 tile += 2;
7643 14658 break;
7644
7645 case 3:
7646 101058 tile += (f4) ? 4 : 3;
7647 101058 break;
7648 }
7649 }
7650 149052 break;
7651
7652 case aWALLM:
7653 {
7654
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 125852 times.
126198 if(!dummy_bool[1])
7655 {
7656 125852 tile += f2;
7657 125852 }
7658 }
7659 126198 break;
7660
7661 case aNEWWALLM:
7662 {
7663 366633 int32_t tempdir=0;
7664
7665
4/4
✓ Branch 0 taken 38855 times.
✓ Branch 1 taken 43340 times.
✓ Branch 2 taken 8438 times.
✓ Branch 3 taken 276000 times.
366633 switch(misc)
7666 {
7667 case 1:
7668 case 2:
7669 43340 tempdir=clk3;
7670 43340 break;
7671
7672 case 3:
7673 case 4:
7674 case 5:
7675 38855 tempdir=dir;
7676 38855 break;
7677
7678 case 6:
7679 case 7:
7680 8438 tempdir=clk3^1;
7681 8438 break;
7682 }
7683
7684 366633 tiledir(tempdir,true);
7685
7686
2/2
✓ Branch 0 taken 1908 times.
✓ Branch 1 taken 364725 times.
366633 if(!dummy_bool[1])
7687 {
7688 364725 tile+=f4;
7689 364725 }
7690 }
7691 366633 break;
7692
7693 case a4FRMNODIR:
7694 {
7695 171508 tile+=f4;
7696 }
7697 171508 break;
7698
7699 } // switch(d->anim)
7700
7701 // flashing
7702 // if(d->flags & guy_flashing)
7703
2/2
✓ Branch 0 taken 38912325 times.
✓ Branch 1 taken 745594 times.
39657919 if(flags & guy_flashing)
7704 {
7705 745594 cs = (frame&3) + 6;
7706 745594 }
7707
7708
2/2
✓ Branch 0 taken 39246971 times.
✓ Branch 1 taken 410948 times.
39657919 if(flags&guy_transparent)
7709 {
7710 410948 drawstyle=1;
7711 410948 }
7712
7713 39657919 int32_t change = tile-basetile;
7714
7715
3/6
✓ Branch 0 taken 2054943 times.
✓ Branch 1 taken 37602976 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2054943 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
39657919 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7716 {
7717
2/2
✓ Branch 0 taken 1792915 times.
✓ Branch 1 taken 262028 times.
2054943 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7718 {
7719 1792915 tile=basetile+txsz*change;
7720 1792915 }
7721 else
7722 {
7723 262028 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7724 }
7725 2054943 }
7726 else
7727 {
7728 37602976 tile=basetile+change;
7729 }
7730 40047240 }
7731
7732 81097 int32_t enemy::wpnsfx(int32_t wpn)
7733 {
7734
3/3
✓ Branch 0 taken 22419 times.
✓ Branch 1 taken 40971 times.
✓ Branch 2 taken 17707 times.
81097 switch (wpn)
7735 {
7736 case wScript1:
7737 case wScript2:
7738 case wScript3:
7739 case wScript4:
7740 case wScript5:
7741 case wScript6:
7742 case wScript7:
7743 case wScript8:
7744 case wScript9:
7745 case wScript10: //sure why not
7746 case ewFireTrail:
7747 case ewFlame:
7748 case ewFlame2Trail:
7749 case ewFlame2:
7750 case ewWind:
7751 case ewMagic:
7752 case ewIce:
7753 22419 return firesfx;
7754
7755 case ewRock:
7756 case ewFireball2:
7757 case ewFireball:
7758
2/2
✓ Branch 0 taken 5539 times.
✓ Branch 1 taken 35432 times.
40971 if (get_qr(qr_MORESOUNDS)) return firesfx;
7759 35432 break;
7760 }
7761
7762 53139 return 0;
7763 81097 }
7764
7765 76720397 int32_t enemy::run_script(int32_t mode)
7766 {
7767 void push_ri();
7768 void pop_ri();
7769
7770
3/4
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 76720141 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 256 times.
76720397 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7771
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76720141 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76720141 if (script <= 0 || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7772 76720141 return RUNSCRIPT_OK;
7773 auto scrty = *get_scrtype();
7774 auto uid = getUID();
7775 if(!FFCore.doscript(scrty,uid))
7776 return RUNSCRIPT_OK;
7777 int32_t ret = RUNSCRIPT_OK;
7778 bool& waitdraw = FFCore.waitdraw(scrty, uid);
7779 push_ri();
7780 switch(mode)
7781 {
7782 case MODE_NORMAL:
7783 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7784 break;
7785
7786 case MODE_WAITDRAW:
7787 if(waitdraw)
7788 {
7789 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, uid);
7790 waitdraw = false;
7791 }
7792 break;
7793 }
7794 pop_ri();
7795 return ret;
7796 76720397 }
7797 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7798 {
7799 return al_map_rgba(255,0,0,opacity);
7800 }
7801
7802 // good guys, fires, fairy, and other non-enemies
7803 // based on enemy class b/c guys in dungeons act sort of like enemies
7804 // also easier to manage all the guys this way
7805 2185 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7806 2185 {
7807 2185 mainguy=mg;
7808 2185 canfreeze=false;
7809 2185 dir=down;
7810
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2185 times.
✓ Branch 2 taken 2185 times.
✗ Branch 3 not taken.
2185 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7811 2185 hxofs=2;
7812 2185 hzsz=8;
7813 2185 hit_width=12;
7814 2185 hit_height=17;
7815
7816
10/12
✓ Branch 0 taken 2185 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2185 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 765 times.
✓ Branch 5 taken 1420 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 22 times.
✓ Branch 8 taken 276 times.
✓ Branch 9 taken 467 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 260 times.
2185 if(!superman && (!isdungeon(screen_spawned) || id==gFAIRY || id==gFIRE || id==gZELDA))
7817 {
7818 1925 superman = 1;
7819 1925 hxofs=1000;
7820 1925 }
7821 2185 }
7822
7823 940991 bool guy::animate(int32_t index)
7824 {
7825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 940991 times.
940991 if(switch_hooked) return enemy::animate(index);
7826
6/6
✓ Branch 0 taken 542419 times.
✓ Branch 1 taken 398572 times.
✓ Branch 2 taken 8294 times.
✓ Branch 3 taken 534125 times.
✓ Branch 4 taken 7090 times.
✓ Branch 5 taken 1204 times.
940991 if(mainguy && clk==0 && misc==0)
7827 {
7828 1204 setupscreen();
7829 1204 misc = 1;
7830 1204 }
7831
7832
4/4
✓ Branch 0 taken 542419 times.
✓ Branch 1 taken 398572 times.
✓ Branch 2 taken 542091 times.
✓ Branch 3 taken 328 times.
940991 if(mainguy && fadeclk==0)
7833 328 return true;
7834
7835 940663 hp=256; // good guys never die...
7836
7837
4/4
✓ Branch 0 taken 922 times.
✓ Branch 1 taken 939741 times.
✓ Branch 2 taken 906 times.
✓ Branch 3 taken 16 times.
940663 if(hclk && !clk2)
7838 {
7839 // but if they get hit...
7840 16 ++clk2; // only do this once
7841
7842
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 7 times.
16 if(!get_qr(qr_NOGUYFIRES))
7843 {
7844 7 addenemy(screen_spawned,BSZ?64:72,68,eSHOOTFBALL,0);
7845 7 addenemy(screen_spawned,BSZ?176:168,68,eSHOOTFBALL,0);
7846 7 }
7847 16 }
7848
7849 940663 return enemy::animate(index);
7850 940991 }
7851
7852 944764 void guy::draw(BITMAP *dest)
7853 {
7854 944764 update_enemy_frame();
7855
7856
6/6
✓ Branch 0 taken 545983 times.
✓ Branch 1 taken 398781 times.
✓ Branch 2 taken 22779 times.
✓ Branch 3 taken 523204 times.
✓ Branch 4 taken 10998 times.
✓ Branch 5 taken 11781 times.
944764 if(!mainguy || fadeclk<0 || fadeclk&1)
7857 932983 enemy::draw(dest);
7858 944764 }
7859
7860 760 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7861 760 {
7862 760 clk4=0;
7863
4/8
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 760 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 760 times.
✗ Branch 7 not taken.
760 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7864 // Spawn type
7865
2/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 760 times.
760 if(flags & guy_fade_flicker)
7866 {
7867 clk=0;
7868 superman = 1;
7869 fading=fade_flicker;
7870 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7871 dir=down;
7872
7873 if(!canmove(down,(zfix)8,spw_none,false))
7874 clk3=int32_t(13.0/step);
7875 }
7876
3/4
✓ Branch 0 taken 760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 676 times.
✓ Branch 3 taken 84 times.
760 else if(flags & guy_fade_instant)
7877 {
7878 84 clk=0;
7879 84 }
7880
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
760 if (SIZEflags != 0) init_size_flags();;
7881 760 }
7882
7883 167472 bool eFire::animate(int32_t index)
7884 {
7885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167472 times.
167472 if(switch_hooked) return enemy::animate(index);
7886
2/4
✓ Branch 0 taken 167472 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 167472 times.
167472 if(fallclk||drownclk) return enemy::animate(index);
7887
2/2
✓ Branch 0 taken 165756 times.
✓ Branch 1 taken 1716 times.
167472 if(fading)
7888 {
7889
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1715 times.
1716 if(++clk4 > 60)
7890 {
7891 1 clk4=0;
7892 1 superman=0;
7893 1 fading=0;
7894
7895
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags&guy_armos && z==0 && fakez==0)
7896 removearmos(x,y,ffcactivated);
7897
7898 1 clk2=0;
7899
7900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!canmove(down,(zfix)8,spw_none,false))
7901 {
7902 1 dir=0;
7903 1 y = TRUNCATE_TILE(y.getInt());
7904 1 }
7905
7906 1 return Dead(index);
7907 }
7908
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1715 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1715 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
7909 removearmos(x,y,ffcactivated);
7910 1715 }
7911
7912 167471 return enemy::animate(index);
7913 167472 }
7914
7915 351659 void eFire::draw(BITMAP *dest)
7916 {
7917 351659 update_enemy_frame();
7918 351659 enemy::draw(dest);
7919 351659 }
7920
7921 415 int32_t eFire::takehit(weapon *w, weapon* realweap)
7922 {
7923 415 int32_t wpnId = w->id;
7924 415 int32_t wpnDir = w->dir;
7925
7926
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
415 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7927 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
7928 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
7929 {
7930 shield = false;
7931 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
7932
7933 if(get_qr(qr_BRKNSHLDTILES))
7934 o_tile=s_tile;
7935 }
7936
7937 415 int32_t ret = enemy::takehit(w,realweap);
7938 415 return ret;
7939 }
7940
7941 void eFire::break_shield()
7942 {
7943 if(!shield)
7944 return;
7945
7946 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
7947 shield=false;
7948
7949 if(get_qr(qr_BRKNSHLDTILES))
7950 o_tile=s_tile;
7951 }
7952
7953 void eFire::repair_shield()
7954 {
7955 if (shield)
7956 return;
7957
7958 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
7959 return;
7960
7961 shield = true;
7962
7963 if (get_qr(qr_BRKNSHLDTILES))
7964 {
7965 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
7966 else o_tile = d->tile;
7967 }
7968 }
7969
7970 7630 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7971 7630 {
7972 7630 clk4=0;
7973
4/8
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7630 times.
✗ Branch 7 not taken.
7630 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
7974
7975 // Spawn type
7976
2/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7630 times.
7630 if(flags & guy_fade_flicker)
7977 {
7978 clk=0;
7979 superman = 1;
7980 fading=fade_flicker;
7981 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7982 dir=down;
7983
7984 if(!canmove(down,(zfix)8,spw_none,false))
7985 clk3=int32_t(13.0/step);
7986 }
7987
3/4
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6443 times.
✓ Branch 3 taken 1187 times.
7630 else if(flags & guy_fade_instant)
7988 {
7989 1187 clk=0;
7990 1187 }
7991
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7623 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
7630 if (SIZEflags != 0) init_size_flags();;
7992 7630 }
7993
7994 1981512 bool eOther::animate(int32_t index)
7995 {
7996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1981512 times.
1981512 if(switch_hooked) return enemy::animate(index);
7997
3/4
✓ Branch 0 taken 1979926 times.
✓ Branch 1 taken 1586 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1979926 times.
1981512 if(fallclk||drownclk) return enemy::animate(index);
7998
2/2
✓ Branch 0 taken 1971390 times.
✓ Branch 1 taken 8536 times.
1979926 if(fading)
7999 {
8000
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 8507 times.
8536 if(++clk4 > 60)
8001 {
8002 29 clk4=0;
8003 29 superman=0;
8004 29 fading=0;
8005
8006
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29 if(flags&guy_armos && z==0 && fakez==0)
8007 removearmos(x,y,ffcactivated);
8008
8009 29 clk2=0;
8010
8011
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 2 times.
29 if(!canmove(down,(zfix)8,spw_none,false))
8012 {
8013 2 dir=0;
8014 2 y = TRUNCATE_TILE(y.getInt());
8015 2 }
8016
8017 29 return Dead(index);
8018 }
8019
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8507 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8020 removearmos(x,y,ffcactivated);
8021 8507 }
8022
8023 1979897 return enemy::animate(index);
8024 1981512 }
8025
8026 2087673 void eOther::draw(BITMAP *dest)
8027 {
8028 2087673 update_enemy_frame();
8029 2087673 enemy::draw(dest);
8030 2087673 }
8031
8032 14773 int32_t eOther::takehit(weapon *w, weapon* realweap)
8033 {
8034 14773 int32_t wpnId = w->id;
8035 14773 int32_t wpnDir = w->dir;
8036
8037
3/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14731 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
14773 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8038 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8039 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8040 {
8041 shield = false;
8042 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8043
8044 if(get_qr(qr_BRKNSHLDTILES))
8045 o_tile=s_tile;
8046 }
8047
8048 14773 int32_t ret = enemy::takehit(w,realweap);
8049 14773 return ret;
8050 }
8051
8052 void eOther::break_shield()
8053 {
8054 if(!shield)
8055 return;
8056
8057 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8058 shield=false;
8059
8060 if(get_qr(qr_BRKNSHLDTILES))
8061 o_tile=s_tile;
8062 }
8063
8064 void eOther::repair_shield()
8065 {
8066 if (shield)
8067 return;
8068
8069 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8070 return;
8071
8072 shield = true;
8073
8074 if (get_qr(qr_BRKNSHLDTILES))
8075 {
8076 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8077 else o_tile = d->tile;
8078 }
8079 }
8080
8081 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8082 {
8083 clk4=0;
8084 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8085
8086 // Spawn type
8087 if(flags & guy_fade_flicker)
8088 {
8089 clk=0;
8090 superman = 1;
8091 fading=fade_flicker;
8092 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8093 dir=down;
8094
8095 if(!canmove(down,(zfix)8,spw_none,false))
8096 clk3=int32_t(13.0/step);
8097 }
8098 else if(flags & guy_fade_instant)
8099 {
8100 clk=0;
8101 }
8102 if (SIZEflags != 0) init_size_flags();;
8103 }
8104
8105 bool eScript::animate(int32_t index)
8106 {
8107 if(switch_hooked) return enemy::animate(index);
8108 if(fallclk||drownclk) return enemy::animate(index);
8109 if(fading)
8110 {
8111 if(++clk4 > 60)
8112 {
8113 clk4=0;
8114 superman=0;
8115 fading=0;
8116
8117 if(flags&guy_armos && z==0 && fakez==0)
8118 removearmos(x,y,ffcactivated);
8119
8120 clk2=0;
8121
8122 if(!canmove(down,(zfix)8,spw_none,false))
8123 {
8124 dir=0;
8125 y = TRUNCATE_TILE(y.getInt());
8126 }
8127
8128 return Dead(index);
8129 }
8130 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8131 removearmos(x,y,ffcactivated);
8132 }
8133
8134 return enemy::animate(index);
8135 }
8136
8137 void eScript::draw(BITMAP *dest)
8138 {
8139 update_enemy_frame();
8140 enemy::draw(dest);
8141 }
8142
8143 int32_t eScript::takehit(weapon *w, weapon* realweap)
8144 {
8145 int32_t wpnId = w->id;
8146 int32_t wpnDir = w->dir;
8147
8148 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8149 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8150 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8151 {
8152 shield = false;
8153 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8154
8155 if(get_qr(qr_BRKNSHLDTILES))
8156 o_tile=s_tile;
8157 }
8158
8159 int32_t ret = enemy::takehit(w,realweap);
8160 return ret;
8161 }
8162
8163 void eScript::break_shield()
8164 {
8165 if(!shield)
8166 return;
8167
8168 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8169 shield=false;
8170
8171 if(get_qr(qr_BRKNSHLDTILES))
8172 o_tile=s_tile;
8173 }
8174
8175 void eScript::repair_shield()
8176 {
8177 if (shield)
8178 return;
8179
8180 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8181 return;
8182
8183 shield = true;
8184
8185 if (get_qr(qr_BRKNSHLDTILES))
8186 {
8187 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8188 else o_tile = d->tile;
8189 }
8190 }
8191
8192
8193 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8194 {
8195 clk4=0;
8196 hyofs = -32768; //No hitbox initially.
8197 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
8198
8199 // Spawn type
8200 if(flags & guy_fade_flicker)
8201 {
8202 clk=0;
8203 superman = 1;
8204 fading=fade_flicker;
8205 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8206 dir=down;
8207
8208 if(!canmove(down,(zfix)8,spw_none,false))
8209 clk3=int32_t(13.0/step);
8210 }
8211 else if(flags & guy_fade_instant)
8212 {
8213 clk=0;
8214 }
8215 if (SIZEflags != 0) init_size_flags();;
8216 }
8217
8218 bool eFriendly::animate(int32_t index)
8219 {
8220 if(switch_hooked) return enemy::animate(index);
8221 if(fallclk||drownclk) return enemy::animate(index);
8222 if(fading)
8223 {
8224 if(++clk4 > 60)
8225 {
8226 clk4=0;
8227 superman=0;
8228 fading=0;
8229
8230 if(flags&guy_armos && z==0 && fakez==0)
8231 removearmos(x,y,ffcactivated);
8232
8233 clk2=0;
8234
8235 if(!canmove(down,(zfix)8,spw_none,false))
8236 {
8237 dir=0;
8238 y = TRUNCATE_TILE(y.getInt());
8239 }
8240
8241 return Dead(index);
8242 }
8243 else if(flags&guy_armos && z==0 && fakez==0 && clk==0)
8244 removearmos(x,y,ffcactivated);
8245 }
8246
8247 return enemy::animate(index);
8248 }
8249
8250 void eFriendly::draw(BITMAP *dest)
8251 {
8252 update_enemy_frame();
8253 enemy::draw(dest);
8254 }
8255
8256 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8257 {
8258 int32_t wpnId = w->id;
8259 int32_t wpnDir = w->dir;
8260
8261 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8262 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
8263 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
8264 {
8265 shield = false;
8266 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
8267
8268 if(get_qr(qr_BRKNSHLDTILES))
8269 o_tile=s_tile;
8270 }
8271
8272 int32_t ret = enemy::takehit(w,realweap);
8273 return ret;
8274 }
8275
8276 void eFriendly::break_shield()
8277 {
8278 if(!shield)
8279 return;
8280
8281 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
8282 shield=false;
8283
8284 if(get_qr(qr_BRKNSHLDTILES))
8285 o_tile=s_tile;
8286 }
8287
8288 void eFriendly::repair_shield()
8289 {
8290 if (shield)
8291 return;
8292
8293 if (!(flags & (guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right)))
8294 return;
8295
8296 shield = true;
8297
8298 if (get_qr(qr_BRKNSHLDTILES))
8299 {
8300 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
8301 else o_tile = d->tile;
8302 }
8303 }
8304
8305
8306 773047 void enemy::removearmos(int32_t ax,int32_t ay, std::optional<ffc_handle_t> ffcactive)
8307 {
8308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 773047 times.
773047 if (ffcactive)
8309 {
8310 removearmosffc(*ffcactive);
8311 return;
8312 }
8313
2/2
✓ Branch 0 taken 772031 times.
✓ Branch 1 taken 1016 times.
773047 if(did_armos)
8314 {
8315 772031 return;
8316 }
8317
8318 1016 auto rpos_handle = get_rpos_handle_for_world_xy(ax, ay, 0);
8319 1016 mapscr* scr = rpos_handle.scr;
8320 1016 ax = TRUNCATE_TILE(ax);
8321 1016 ay = TRUNCATE_TILE(ay);
8322
8323 1016 did_armos=true;
8324 1016 int32_t cd = rpos_handle.pos;
8325 1016 int32_t f = rpos_handle.sflag();
8326 1016 int32_t f2 = rpos_handle.cflag();
8327
8328
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 176 times.
1016 if (rpos_handle.ctype() != cARMOS)
8329 {
8330 840 return;
8331 }
8332
8333 176 scr->data[cd] = scr->undercombo;
8334 176 scr->cset[cd] = scr->undercset;
8335 176 scr->sflag[cd] = 0;
8336
8337
3/4
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154 times.
176 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8338 {
8339 22 scr->data[cd] = scr->secretcombo[sSTAIRS];
8340 22 scr->cset[cd] = scr->secretcset[sSTAIRS];
8341 22 scr->sflag[cd]=scr->secretflag[sSTAIRS];
8342 22 sfx(scr->secretsfx);
8343 22 }
8344
8345
3/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 173 times.
176 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8346 {
8347
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8348 {
8349 3 additem(ax,ay,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8350 3 sfx(scr->secretsfx);
8351 3 }
8352 3 }
8353
8354 176 putcombo(scrollbuf,ax,ay,scr->data[cd],scr->cset[cd]);
8355 773047 }
8356
8357 void enemy::removearmosffc(const ffc_handle_t& ffc_handle)
8358 {
8359 if(did_armos)
8360 {
8361 return;
8362 }
8363
8364 did_armos=true;
8365 ffcdata& ffc = *ffc_handle.ffc;
8366 mapscr* scr = ffc_handle.scr;
8367 auto& cmb = ffc_handle.combo();
8368 int32_t f2 = cmb.flag;
8369
8370 if(cmb.type!=cARMOS)
8371 {
8372 return;
8373 }
8374
8375 ffc_handle.set_data(scr->undercombo);
8376 ffc_handle.set_cset(scr->undercset);
8377
8378 if(f2 == mfARMOS_SECRET)
8379 {
8380 ffc_handle.set_data(scr->secretcombo[sSTAIRS]);
8381 ffc_handle.set_cset(scr->secretcset[sSTAIRS]);
8382 sfx(scr->secretsfx);
8383 }
8384
8385 if(f2 == mfARMOS_ITEM)
8386 {
8387 if(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN))
8388 {
8389 additem(ffc.x,ffc.y,scr->catchall, (ipONETIME2 + ipBIGRANGE) | ((scr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8390 sfx(scr->secretsfx);
8391 }
8392 }
8393
8394 putcombo(scrollbuf,ffc.x,ffc.y,ffc_handle.data(),ffc.cset);
8395 }
8396
8397
8398 461 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8399 461 {
8400 461 fading=fade_flicker;
8401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8402 461 dir=12;
8403 461 movestatus=1;
8404
1/2
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
461 step=0;
8405 461 clk=0;
8406 461 clk4=0;
8407
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
461 if (SIZEflags != 0) init_size_flags();;
8408 461 }
8409
8410 117025 bool eGhini::animate(int32_t index)
8411 {
8412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117025 times.
117025 if(switch_hooked) return enemy::animate(index);
8413
2/4
✓ Branch 0 taken 117025 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 117025 times.
117025 if(fallclk||drownclk) return enemy::animate(index);
8414
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 116975 times.
117025 if(dying)
8415 50 return Dead(index);
8416
8417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116975 times.
116975 if(dmisc1)
8418 {
8419
2/2
✓ Branch 0 taken 89752 times.
✓ Branch 1 taken 27223 times.
116975 if(misc)
8420 {
8421
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 if(clk4>160)
8422 54853 misc=2;
8423
8424
2/2
✓ Branch 0 taken 34899 times.
✓ Branch 1 taken 54853 times.
89752 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8425 89752 removearmos(x,y,ffcactivated);
8426 89752 }
8427
2/2
✓ Branch 0 taken 26798 times.
✓ Branch 1 taken 425 times.
27223 else if(clk4>=60)
8428 {
8429 425 misc=1;
8430 425 clk3=32;
8431 425 fading=0;
8432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 425 times.
425 if (ffcactivated)
8433 {
8434 activation_counters_ffc[ffcactivated->id] = 0;
8435 removearmosffc(*ffcactivated);
8436 }
8437 else
8438 {
8439 425 rpos_t rpos = COMBOPOS_REGION_B(x, y);
8440
1/2
✓ Branch 0 taken 425 times.
✗ Branch 1 not taken.
425 if (rpos != rpos_t::None)
8441 {
8442 425 activation_counters[(int)rpos] = 0;
8443 425 removearmos(x,y);
8444 425 }
8445 }
8446 425 }
8447 116975 }
8448
8449 116975 clk4++;
8450
8451 116975 return enemy::animate(index);
8452 117025 }
8453
8454 238808 void eGhini::draw(BITMAP *dest)
8455 {
8456 238808 update_enemy_frame();
8457 238808 enemy::draw(dest);
8458 238808 }
8459
8460 2 void eGhini::kickbucket()
8461 {
8462 2 hp=-1000; // don't call death_sfx()
8463 2 }
8464
8465
2/4
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
10424 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8466 5212 {
8467
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 old_y=y;
8468 5212 dir=down;
8469 5212 misc=1;
8470 5212 clk=-15;
8471
8472
2/2
✓ Branch 0 taken 2649 times.
✓ Branch 1 taken 2563 times.
5212 if(!BSZ)
8473
1/2
✓ Branch 0 taken 2649 times.
✗ Branch 1 not taken.
2649 clk*=zc_oldrand()%3+1;
8474
8475 // avoid divide by 0 errors
8476
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc1 == 0)
8477 dmisc1 = 24;
8478
8479
1/2
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
5212 if(dmisc2 == 0)
8480 dmisc2 = 3;
8481
8482 //nets+760;
8483
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5212 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5212 if (SIZEflags != 0) init_size_flags();;
8484 5212 }
8485
8486 1436598 bool eTektite::animate(int32_t index)
8487 {
8488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1436598 times.
1436598 if(switch_hooked) return enemy::animate(index);
8489
4/4
✓ Branch 0 taken 1427644 times.
✓ Branch 1 taken 8954 times.
✓ Branch 2 taken 8954 times.
✓ Branch 3 taken 1425286 times.
1436598 if(fallclk||drownclk) return enemy::animate(index);
8490
2/2
✓ Branch 0 taken 26667 times.
✓ Branch 1 taken 1398619 times.
1425286 if(dying)
8491 26667 return Dead(index);
8492
8493
2/2
✓ Branch 0 taken 1361516 times.
✓ Branch 1 taken 37103 times.
1398619 if(clk==0)
8494 {
8495 37103 removearmos(x,y,ffcactivated);
8496 37103 }
8497
8498
2/2
✓ Branch 0 taken 1057436 times.
✓ Branch 1 taken 341183 times.
1398619 if(get_qr(qr_ENEMIESZAXIS))
8499 {
8500 341183 y=floor_y;
8501 341183 }
8502
8503
9/10
✓ Branch 0 taken 1283739 times.
✓ Branch 1 taken 114880 times.
✓ Branch 2 taken 1270175 times.
✓ Branch 3 taken 13564 times.
✓ Branch 4 taken 1270175 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 1258999 times.
✓ Branch 8 taken 11916 times.
✓ Branch 9 taken 21878 times.
1398619 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8504 {
8505
4/4
✓ Branch 0 taken 20260 times.
✓ Branch 1 taken 421702 times.
✓ Branch 2 taken 345150 times.
✓ Branch 3 taken 493765 times.
1280877 switch(misc)
8506 {
8507 case 0: // normal
8508
2/2
✓ Branch 0 taken 410469 times.
✓ Branch 1 taken 11233 times.
421702 if (!zc::math::SafeMod(zc_oldrand(), dmisc1))
8509 {
8510 11233 misc=1;
8511 11233 clk2=32;
8512 11233 }
8513
8514 421702 break;
8515
8516 case 1: // waiting to pounce
8517
2/2
✓ Branch 0 taken 324515 times.
✓ Branch 1 taken 20635 times.
345150 if(--clk2<=0)
8518 {
8519 20635 int32_t r=zc_oldrand();
8520 20635 misc=2;
8521 20635 step=0-(zslongToFix(dstep*100)); // initial speed
8522 20635 clk3=(r&1)+2; // left or right
8523 20635 clk2start=clk2=(r&31)+10; // flight time
8524
8525
2/2
✓ Branch 0 taken 18212 times.
✓ Branch 1 taken 2423 times.
20635 if(y<32) clk2+=2; // make them come down from top of screen
8526
8527
2/2
✓ Branch 0 taken 15717 times.
✓ Branch 1 taken 4918 times.
20635 if(y>world_h-64) clk2-=2; // make them go back up
8528
8529 20635 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8530 20635 }
8531
8532 345150 break;
8533
8534 case 2: // in flight
8535 493765 move(step);
8536
8537
2/2
✓ Branch 0 taken 234357 times.
✓ Branch 1 taken 259408 times.
493765 if(step>0) //going down
8538 {
8539
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 233725 times.
234357 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8540 {
8541 632 step=0-step;
8542 632 }
8543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8544 {
8545 step=0-step;
8546 }
8547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 233725 times.
233725 else if(ispitfall(x+8,y+16))
8548 {
8549 step=0-step;
8550 }
8551
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 233678 times.
233725 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8552 {
8553 47 step=0-step;
8554 47 }
8555
2/2
✓ Branch 0 taken 233667 times.
✓ Branch 1 taken 11 times.
233678 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8556 {
8557 11 step=0-step;
8558 11 }
8559 234357 }
8560
2/2
✓ Branch 0 taken 15166 times.
✓ Branch 1 taken 244242 times.
259408 else if(step<0)
8561 {
8562
2/2
✓ Branch 0 taken 438 times.
✓ Branch 1 taken 243804 times.
244242 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8563 {
8564 438 step=0-step;
8565 438 }
8566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8567 {
8568 step=0-step;
8569 }
8570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243804 times.
243804 else if(ispitfall(x+8,y))
8571 {
8572 step=0-step;
8573 }
8574
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 243783 times.
243804 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8575 {
8576 21 step=0-step;
8577 21 }
8578
2/2
✓ Branch 0 taken 243764 times.
✓ Branch 1 taken 19 times.
243783 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8579 {
8580 19 step=0-step;
8581 19 }
8582 244242 }
8583
8584
2/2
✓ Branch 0 taken 244331 times.
✓ Branch 1 taken 249434 times.
493765 if(clk3==left)
8585 {
8586
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 244056 times.
244331 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8587 {
8588 275 clk3^=1;
8589 275 }
8590
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 244050 times.
244056 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8591 {
8592 6 clk3^=1;
8593 6 }
8594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244050 times.
244050 else if(ispitfall(x,y+8))
8595 {
8596 clk3^=1;
8597 }
8598
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 244020 times.
244050 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8599 {
8600 30 clk3^=1;
8601 30 }
8602
2/2
✓ Branch 0 taken 244008 times.
✓ Branch 1 taken 12 times.
244020 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8603 {
8604 12 clk3^=1;
8605 12 }
8606 244331 }
8607 else
8608 {
8609
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 249158 times.
249434 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8610 {
8611 276 clk3^=1;
8612 276 }
8613
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 249146 times.
249158 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8614 {
8615 12 clk3^=1;
8616 12 }
8617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249146 times.
249146 else if(ispitfall(x+16,y+8))
8618 {
8619 clk3^=1;
8620 }
8621
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 249141 times.
249146 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8622 {
8623 5 clk3^=1;
8624 5 }
8625
2/2
✓ Branch 0 taken 249129 times.
✓ Branch 1 taken 12 times.
249141 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8626 {
8627 12 clk3^=1;
8628 12 }
8629 }
8630
8631 493765 --c;
8632
8633
4/4
✓ Branch 0 taken 151531 times.
✓ Branch 1 taken 342234 times.
✓ Branch 2 taken 320688 times.
✓ Branch 3 taken 173077 times.
493765 if(c<0 && step<zslongToFix(dstep*100))
8634 {
8635 173077 step+=zslongToFix(dmisc3*100);
8636 173077 }
8637
8638 493765 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8639
8640
2/2
✓ Branch 0 taken 493043 times.
✓ Branch 1 taken 722 times.
493765 if(x<=16-nb) clk3=right;
8641
8642
2/2
✓ Branch 0 taken 492773 times.
✓ Branch 1 taken 992 times.
493765 if(x>=world_w-32+nb) clk3=left;
8643
8644 493765 x += (clk3==left) ? -1 : 1;
8645
8646
4/4
✓ Branch 0 taken 29039 times.
✓ Branch 1 taken 464726 times.
✓ Branch 2 taken 10130 times.
✓ Branch 3 taken 454596 times.
493765 if((--clk2<=0 && y>=16-nb) || y>=world_h-32+nb)
8647 {
8648
4/4
✓ Branch 0 taken 1621 times.
✓ Branch 1 taken 17288 times.
✓ Branch 2 taken 1436 times.
✓ Branch 3 taken 185 times.
39169 if(y>=world_h-32+nb && get_qr(qr_ENEMIESZAXIS))
8649 {
8650 185 step=0-step;
8651 185 y--;
8652 185 }
8653
2/2
✓ Branch 0 taken 5796 times.
✓ Branch 1 taken 12928 times.
18724 else if (zc::math::SafeMod(zc_oldrand(), dmisc2)) //land and wait
8654 {
8655 12928 clk=misc=0;
8656 12928 } //land and jump again
8657 else
8658 {
8659 5796 misc=1;
8660 5796 clk2=0;
8661 }
8662 18909 }
8663
8664 473505 break;
8665 } // switch
8666 1260617 }
8667
8668
4/4
✓ Branch 0 taken 341183 times.
✓ Branch 1 taken 1059794 times.
✓ Branch 2 taken 231206 times.
✓ Branch 3 taken 109977 times.
1400977 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8669 {
8670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109977 times.
109977 if (moveflags & move_use_fake_z)
8671 {
8672 int32_t tempy = floor_y;
8673 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8674 floor_y = y;
8675 y=tempy-fakez;
8676 old_y = y;
8677 }
8678 else
8679 {
8680 109977 int32_t tempy = floor_y;
8681
6/6
✓ Branch 0 taken 55216 times.
✓ Branch 1 taken 54761 times.
✓ Branch 2 taken 104073 times.
✓ Branch 3 taken 5904 times.
✓ Branch 4 taken 50747 times.
✓ Branch 5 taken 53326 times.
109977 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8682 109977 floor_y = y;
8683 109977 y=tempy-z;
8684 109977 old_y = y;
8685 }
8686 109977 }
8687
8688
4/4
✓ Branch 0 taken 13564 times.
✓ Branch 1 taken 1387413 times.
✓ Branch 2 taken 2927 times.
✓ Branch 3 taken 10637 times.
1400977 if(stunclk && (clk&31)==1)
8689 10637 clk=0;
8690
8691 1400977 return enemy::animate(index);
8692 1427644 }
8693
8694 809450 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8695 {
8696
5/6
✓ Branch 0 taken 632172 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 632172 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 606981 times.
✓ Branch 5 taken 25191 times.
809450 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8697 25191 return;
8698
8699 784259 int32_t tempy=yofs;
8700 784259 int32_t fdiv = frate/4;
8701
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8702
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8703 784259 efrate:((clk>=(frate>>1))?1:0);
8704 784259 flip = 0;
8705 784259 shadowtile = wpnsbuf[spr_shadow].tile;
8706
8707
1/2
✓ Branch 0 taken 784259 times.
✗ Branch 1 not taken.
784259 if(get_qr(qr_NEWENEMYTILES))
8708 {
8709
2/2
✓ Branch 0 taken 581728 times.
✓ Branch 1 taken 202531 times.
784259 if(misc==0)
8710 {
8711 202531 shadowtile+=f2;
8712 202531 }
8713
2/2
✓ Branch 0 taken 259363 times.
✓ Branch 1 taken 322365 times.
581728 else if(misc!=1)
8714 322365 shadowtile+=2;
8715 784259 }
8716 else
8717 {
8718 if(misc==0)
8719 {
8720 shadowtile += f2 ? 1 : 0;
8721 }
8722 else if(misc!=1)
8723 {
8724 ++shadowtile;
8725 }
8726 }
8727
8728 784259 yofs+=8;
8729
8730
4/4
✓ Branch 0 taken 606981 times.
✓ Branch 1 taken 177278 times.
✓ Branch 2 taken 344816 times.
✓ Branch 3 taken 262165 times.
784259 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8731 {
8732
6/6
✓ Branch 0 taken 134327 times.
✓ Branch 1 taken 127838 times.
✓ Branch 2 taken 244709 times.
✓ Branch 3 taken 17456 times.
✓ Branch 4 taken 123717 times.
✓ Branch 5 taken 120992 times.
262165 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8733 262165 }
8734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784259 times.
784259 if(!shadow_overpit(this))
8735 784259 enemy::drawshadow(dest,translucent);
8736 784259 yofs=tempy;
8737 809450 }
8738
8739 2052032 void eTektite::draw(BITMAP *dest)
8740 {
8741 2052032 update_enemy_frame();
8742 2052032 enemy::draw(dest);
8743 2052032 }
8744
8745 731 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8746 731 {
8747
2/4
✓ Branch 0 taken 731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 731 times.
✗ Branch 3 not taken.
731 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8748 731 superman=1;
8749 731 dir=8;
8750 731 hxofs=1000;
8751 731 mainguy=false;
8752 731 count_enemy=false;
8753
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 731 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
731 if (SIZEflags != 0) init_size_flags();;
8754 731 }
8755
8756 280190 bool eItemFairy::animate(int32_t index)
8757 {
8758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280190 times.
280190 if(switch_hooked) return enemy::animate(index);
8759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280190 times.
280190 if(dying)
8760 return Dead(index);
8761
8762 //if(clk>32)
8763 280190 misc=1;
8764 280190 bool w=watch;
8765 280190 watch=false;
8766 280190 variable_walk_8(misc?3:0,0,8,spw_floater);
8767 280190 watch=w;
8768
8769
2/2
✓ Branch 0 taken 1515 times.
✓ Branch 1 taken 278675 times.
280190 if(clk==0)
8770 {
8771 1515 removearmos(x,y,ffcactivated);
8772 1515 }
8773
8774 280190 return enemy::animate(index);
8775 280190 }
8776
8777 562738 void eItemFairy::draw(BITMAP *dest)
8778 {
8779 //these are here to bypass compiler warnings about unused arguments
8780 562738 dest=dest;
8781 562738 }
8782
8783 1825 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8784 1825 {
8785 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8786
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1825 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1825 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1825 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1825 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1825 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1825 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1825 times.
✗ Branch 19 not taken.
1825 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8787 1825 dir=8;
8788 1825 movestatus=1;
8789 1825 clk=0;
8790
1/2
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
1825 step=0;
8791 //nets+720;
8792
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1825 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1825 if (SIZEflags != 0) init_size_flags();;
8793 1825 }
8794
8795 520615 bool ePeahat::animate(int32_t index)
8796 {
8797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 520615 times.
520615 if(switch_hooked) return enemy::animate(index);
8798
2/4
✓ Branch 0 taken 520615 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 520615 times.
520615 if(fallclk||drownclk) return enemy::animate(index);
8799
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 520537 times.
520615 if(slide())
8800 {
8801 78 return false;
8802 }
8803
8804
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 519507 times.
520537 if(dying)
8805 1030 return Dead(index);
8806
8807
2/2
✓ Branch 0 taken 3083 times.
✓ Branch 1 taken 516424 times.
519507 if(clk==0)
8808 {
8809 3083 removearmos(x,y,ffcactivated);
8810 3083 }
8811
8812
4/4
✓ Branch 0 taken 516389 times.
✓ Branch 1 taken 3118 times.
✓ Branch 2 taken 253336 times.
✓ Branch 3 taken 263053 times.
519507 if(stunclk==0 && clk>96)
8813 263053 misc=1;
8814
8815
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
519507 if(!watch)
8816
2/2
✓ Branch 0 taken 171491 times.
✓ Branch 1 taken 345614 times.
517105 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8817
8818
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 419489 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
519507 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8819 {
8820
1/2
✓ Branch 0 taken 100018 times.
✗ Branch 1 not taken.
100018 if (moveflags & move_use_fake_z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8821 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8822 100018 }
8823
8824
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 517105 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
519507 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8825 1634 superman=0;
8826 else
8827
2/2
✓ Branch 0 taken 9811 times.
✓ Branch 1 taken 508062 times.
517873 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8828 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8829
2/2
✓ Branch 0 taken 264937 times.
✓ Branch 1 taken 254570 times.
519507 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8830 {
8831
2/2
✓ Branch 0 taken 261822 times.
✓ Branch 1 taken 3115 times.
264937 if ( stunclk ) --stunclk;
8832 264937 }
8833 254570 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8834 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8835
8836
8837
2/2
✓ Branch 0 taken 519267 times.
✓ Branch 1 taken 240 times.
519507 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8838
8839 519507 return enemy::animate(index);
8840 520615 }
8841
8842 334520 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8843 {
8844 334520 int32_t tempy=yofs;
8845 334520 flip = 0;
8846 334520 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8847
8848
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 246431 times.
334520 if(!get_qr(qr_ENEMIESZAXIS))
8849 {
8850 246431 yofs+=8;
8851 246431 yofs+=int32_t(step/zslongToFix(dstep*10));
8852 246431 }
8853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334520 times.
334520 if(!shadow_overpit(this))
8854 334520 enemy::drawshadow(dest,translucent);
8855 334520 yofs=tempy;
8856 334520 }
8857
8858 1144330 void ePeahat::draw(BITMAP *dest)
8859 {
8860 1144330 update_enemy_frame();
8861 1144330 enemy::draw(dest);
8862 1144330 }
8863
8864 4136 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8865 {
8866 4136 int32_t wpnId = w->id;
8867 4136 int32_t enemyHitWeapon = w->parentitem;
8868
8869
3/6
✓ Branch 0 taken 4136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4136 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4136 times.
4136 if(dying || clk<0 || hclk>0)
8870 return 0;
8871
8872
4/4
✓ Branch 0 taken 3381 times.
✓ Branch 1 taken 755 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 206 times.
4380 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8873 // fire boomerang, for nailing peahats
8874
4/6
✓ Branch 0 taken 3381 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3137 times.
✓ Branch 3 taken 244 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 244 times.
3381 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8875 3343 return 0;
8876
8877 // Time for a kludge...
8878 793 int32_t s = superman;
8879 793 superman = 0;
8880 793 int32_t ret = enemy::takehit(w,realweap);
8881 793 superman = s;
8882
8883 // Anyway...
8884
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 192 times.
793 if(stunclk == 160)
8885 {
8886 192 clk2=0;
8887 192 movestatus=0;
8888 192 misc=0;
8889 192 clk=0;
8890 192 step=0;
8891 192 }
8892
8893 793 return ret;
8894 4136 }
8895
8896 // auomatically kill off enemy (for rooms with ringleaders)
8897 void ePeahat::kickbucket()
8898 {
8899 hp=-1000; // don't call death_sfx()
8900 }
8901
8902 3942 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8903 3942 {
8904 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8905
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 2147 times.
3942 if(dmisc1==0)
8906 {
8907 2147 misc=-1; //Line of Sight leevers
8908 2147 clk-=16;
8909 2147 }
8910 3942 clk3 = 0;
8911 //nets+1460;
8912 3942 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8913 3942 submerged = false;
8914
1/4
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3942 if (SIZEflags != 0) init_size_flags();;
8915 3942 }
8916
8917 923 bool eLeever::isSubmerged() const
8918 {
8919 923 return misc <= 0;
8920 }
8921
8922 1018478 bool eLeever::animate(int32_t index)
8923 {
8924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1018478 times.
1018478 if(switch_hooked) return enemy::animate(index);
8925
3/4
✓ Branch 0 taken 1018123 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1018123 times.
1018478 if(fallclk||drownclk)
8926 {
8927 355 return enemy::animate(index);
8928 }
8929
2/2
✓ Branch 0 taken 31552 times.
✓ Branch 1 taken 986571 times.
1018123 if(dying)
8930 31552 return Dead(index);
8931
8932
2/2
✓ Branch 0 taken 941601 times.
✓ Branch 1 taken 44970 times.
986571 if(clk==0)
8933 {
8934 44970 removearmos(x,y,ffcactivated);
8935 44970 }
8936
8937
4/4
✓ Branch 0 taken 816947 times.
✓ Branch 1 taken 169624 times.
✓ Branch 2 taken 5265 times.
✓ Branch 3 taken 811682 times.
986571 if(clk>=0 && !slide())
8938 {
8939
2/2
✓ Branch 0 taken 337868 times.
✓ Branch 1 taken 473814 times.
811682 switch(dmisc1)
8940 {
8941 case 0: //line of sight
8942 case 2:
8943
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 124459 times.
✓ Branch 2 taken 49109 times.
✓ Branch 3 taken 35464 times.
✓ Branch 4 taken 15780 times.
✓ Branch 5 taken 101784 times.
✓ Branch 6 taken 4365 times.
✓ Branch 7 taken 6907 times.
337868 switch(misc) //is this leever active
8944 {
8945 case -1: //submerged
8946 {
8947
4/6
✓ Branch 0 taken 6382 times.
✓ Branch 1 taken 118077 times.
✓ Branch 2 taken 6382 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6382 times.
124459 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
8948
4/4
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 114160 times.
✓ Branch 2 taken 10261 times.
✓ Branch 3 taken 38 times.
124459 if((dmisc1==2)&&(zc_oldrand()&255))
8949 {
8950 10261 break;
8951 }
8952
8953 114198 int32_t active=0;
8954
8955
2/2
✓ Branch 0 taken 783342 times.
✓ Branch 1 taken 114198 times.
897540 for(int32_t i=0; i<guys.Count(); i++)
8956 {
8957
4/4
✓ Branch 0 taken 627294 times.
✓ Branch 1 taken 156048 times.
✓ Branch 2 taken 401598 times.
✓ Branch 3 taken 225696 times.
783342 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
8958 {
8959 225696 ++active;
8960 225696 }
8961 783342 }
8962
8963
2/2
✓ Branch 0 taken 112327 times.
✓ Branch 1 taken 1871 times.
114198 if(active<((dmisc1==2)?1:2))
8964 {
8965 1871 misc=0; //activate this one
8966 1871 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
8967 1871 }
8968 }
8969 114198 break;
8970
8971 case 0:
8972 {
8973
8974
4/6
✓ Branch 0 taken 11920 times.
✓ Branch 1 taken 37189 times.
✓ Branch 2 taken 11920 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11920 times.
49109 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
8975 {
8976 misc=1;
8977 clk2=0;
8978 }
8979
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 49052 times.
49109 else if (clk3<=0)
8980 {
8981 57 misc = -1;
8982 57 break;
8983 }
8984 49052 int32_t s=0;
8985
8986
2/2
✓ Branch 0 taken 273250 times.
✓ Branch 1 taken 49052 times.
322302 for(int32_t i=0; i<guys.Count(); i++)
8987 {
8988
4/4
✓ Branch 0 taken 164314 times.
✓ Branch 1 taken 108936 times.
✓ Branch 2 taken 156432 times.
✓ Branch 3 taken 7882 times.
273250 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
8989 {
8990 7882 ++s;
8991 7882 }
8992 273250 }
8993
8994
2/2
✓ Branch 0 taken 7882 times.
✓ Branch 1 taken 41170 times.
49052 if(s>0)
8995 {
8996 7882 break;
8997 }
8998
8999 41170 int32_t d2=zc_oldrand()&1;
9000
9001
2/2
✓ Branch 0 taken 14509 times.
✓ Branch 1 taken 26661 times.
41170 if(HeroDir()>=left)
9002 {
9003 26661 d2+=2;
9004 26661 }
9005
9006
4/4
✓ Branch 0 taken 39722 times.
✓ Branch 1 taken 1448 times.
✓ Branch 2 taken 663 times.
✓ Branch 3 taken 39059 times.
41170 if(canplace(d2) || canplace(d2^1))
9007 {
9008 2111 misc=1;
9009 2111 clk2=0;
9010 2111 clk=0;
9011 2111 }
9012 }
9013 41170 break;
9014
9015 case 1:
9016
9017
7/8
✓ Branch 0 taken 33397 times.
✓ Branch 1 taken 2067 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 29801 times.
✓ Branch 4 taken 3596 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3595 times.
35464 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9018
9019 35464 break;
9020
9021 case 2:
9022
9023
7/8
✓ Branch 0 taken 13865 times.
✓ Branch 1 taken 1915 times.
✓ Branch 2 taken 1503 times.
✓ Branch 3 taken 12362 times.
✓ Branch 4 taken 1503 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1502 times.
15780 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9024
9025 15780 break;
9026
9027 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9028 case 3:
9029
9030
5/6
✓ Branch 0 taken 98195 times.
✓ Branch 1 taken 3589 times.
✓ Branch 2 taken 98195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2727 times.
✓ Branch 5 taken 95468 times.
101784 if(stunclk || frozenclock || watch) break;
9031
9032
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 95326 times.
95468 if(scored) dir^=1;
9033
9034
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 94963 times.
95468 if(!canmove(dir,false)) misc=4;
9035 94963 else move(zslongToFix(dstep*100));
9036
9037 95468 break;
9038
9039 case 4:
9040
4/6
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 3755 times.
✓ Branch 2 taken 610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 610 times.
4365 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9041
2/2
✓ Branch 0 taken 3897 times.
✓ Branch 1 taken 468 times.
4365 if(--clk2<=16)
9042 {
9043 468 misc=5;
9044 468 clk=8;
9045 468 }
9046
9047 4365 break;
9048
9049 case 5:
9050
5/6
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 5897 times.
✓ Branch 2 taken 1010 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1009 times.
6907 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9051
2/2
✓ Branch 0 taken 6497 times.
✓ Branch 1 taken 410 times.
6907 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9052
9053 6907 break;
9054 } // switch(misc)
9055
9056 337868 break;
9057
9058 default: //random
9059 // step=d->misc3/100.0;
9060
9061 473814 step=zslongToFix(dmisc3*100);
9062
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 473814 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473814 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9063 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9064 {
9065 if (clk2 < 48) clk2+=2;
9066 if (clk2 >= 300) clk2-=2;
9067 }
9068
9069
2/2
✓ Branch 0 taken 60840 times.
✓ Branch 1 taken 412974 times.
473814 if(clk2<32) misc=1;
9070
2/2
✓ Branch 0 taken 30244 times.
✓ Branch 1 taken 382730 times.
412974 else if(clk2<48) misc=2;
9071
2/2
✓ Branch 0 taken 289541 times.
✓ Branch 1 taken 93189 times.
382730 else if(clk2<300)
9072 {
9073 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9074 {
9075 fix_coords();
9076 }*/
9077 289541 misc=3;
9078 289541 step = zslongToFix(dstep*100);
9079 289541 }
9080
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 84180 times.
93189 else if(clk2<316) misc=2;
9081
2/2
✓ Branch 0 taken 43755 times.
✓ Branch 1 taken 40425 times.
84180 else if(clk2<412) misc=1;
9082
2/2
✓ Branch 0 taken 40151 times.
✓ Branch 1 taken 274 times.
40425 else if(clk2<540)
9083 {
9084 40151 misc=0;
9085 40151 step=0;
9086 40151 }
9087 274 else clk2=0;
9088
9089
2/2
✓ Branch 0 taken 471961 times.
✓ Branch 1 taken 1853 times.
473814 if(clk2==48) clk=0;
9090
9091 // variable_walk(d->rate, d->homing, 0);
9092 473814 variable_walk(rate, homing, 0);
9093 473814 } // switch(dmisc1)
9094 811682 }
9095
9096 986571 hxofs=(misc>=2)?0:1000;
9097 986571 return enemy::animate(index);
9098 1018478 }
9099
9100 80892 bool eLeever::canplace(int32_t d2)
9101 {
9102 80892 int32_t nx=HeroX();
9103 80892 int32_t ny=HeroY();
9104
9105
2/2
✓ Branch 0 taken 28492 times.
✓ Branch 1 taken 52400 times.
80892 if(d2<left) ny=TRUNCATE_TILE(ny);
9106 52400 else nx=TRUNCATE_TILE(nx);
9107
9108
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 14174 times.
✓ Branch 2 taken 14318 times.
✓ Branch 3 taken 26181 times.
✓ Branch 4 taken 26219 times.
80892 switch(d2)
9109 {
9110 case up:
9111
2/2
✓ Branch 0 taken 14144 times.
✓ Branch 1 taken 30 times.
14174 ny-=((dmisc1==0||dmisc1==2)?32:48);
9112 14174 break;
9113
9114 case down:
9115
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 14284 times.
14318 ny+=((dmisc1==0||dmisc1==2)?32:48);
9116
9117
4/4
✓ Branch 0 taken 10087 times.
✓ Branch 1 taken 4231 times.
✓ Branch 2 taken 10076 times.
✓ Branch 3 taken 11 times.
14318 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9118
9119 14318 break;
9120
9121 case left:
9122
2/2
✓ Branch 0 taken 25528 times.
✓ Branch 1 taken 653 times.
26181 nx-=((dmisc1==0||dmisc1==2)?32:48);
9123 26181 break;
9124
9125 case right:
9126
2/2
✓ Branch 0 taken 646 times.
✓ Branch 1 taken 25573 times.
26219 nx+=((dmisc1==0||dmisc1==2)?32:48);
9127
9128
4/4
✓ Branch 0 taken 19151 times.
✓ Branch 1 taken 7068 times.
✓ Branch 2 taken 18549 times.
✓ Branch 3 taken 602 times.
26219 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9129
9130 26219 break;
9131 }
9132
9133
4/4
✓ Branch 0 taken 20429 times.
✓ Branch 1 taken 60463 times.
✓ Branch 2 taken 9001 times.
✓ Branch 3 taken 11428 times.
80892 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9134 69464 return false;
9135
9136
2/2
✓ Branch 0 taken 865 times.
✓ Branch 1 taken 10563 times.
11428 if(d2>=left)
9137
4/4
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 5538 times.
✓ Branch 2 taken 9317 times.
✓ Branch 3 taken 1246 times.
10563 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9138 9317 return false;
9139
9140 2111 x=nx;
9141 2111 y=ny;
9142 2111 dir=d2^1;
9143 2111 return true;
9144 80892 }
9145
9146 1024382 void eLeever::draw(BITMAP *dest)
9147 {
9148 // cs=d->cset;
9149 1024382 cs=dcset;
9150 1024382 update_enemy_frame();
9151
3/4
✓ Branch 0 taken 1024027 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1024027 times.
1024382 if(!fallclk&&!drownclk)
9152 {
9153
2/2
✓ Branch 0 taken 637088 times.
✓ Branch 1 taken 386939 times.
1024027 switch(misc)
9154 {
9155 case -1:
9156 case 0:
9157 386939 return;
9158 }
9159 637088 }
9160
9161 637443 enemy::draw(dest);
9162 1024382 }
9163
9164 986 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9165 986 {
9166 986 hashero=false;
9167 //nets+1000;
9168
1/4
✓ Branch 0 taken 986 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
986 if (SIZEflags != 0) init_size_flags();;
9169 986 }
9170
9171 490648 bool eWallM::animate(int32_t index)
9172 {
9173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490648 times.
490648 if(switch_hooked) return enemy::animate(index);
9174
2/4
✓ Branch 0 taken 490648 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 490648 times.
490648 if(fallclk||drownclk)
9175 {
9176 return enemy::animate(index);
9177 }
9178
2/2
✓ Branch 0 taken 9784 times.
✓ Branch 1 taken 480864 times.
490648 if(dying)
9179 9784 return Dead(index);
9180
9181
2/2
✓ Branch 0 taken 450757 times.
✓ Branch 1 taken 30107 times.
480864 if(clk==0)
9182 {
9183 30107 removearmos(x,y,ffcactivated);
9184 30107 }
9185
9186 480864 hxofs=1000;
9187
2/2
✓ Branch 0 taken 115663 times.
✓ Branch 1 taken 365201 times.
480864 if(misc==0) //inside wall, ready to spawn?
9188 {
9189
4/4
✓ Branch 0 taken 217551 times.
✓ Branch 1 taken 147650 times.
✓ Branch 2 taken 16531 times.
✓ Branch 3 taken 201020 times.
365201 if(frame-wallm_load_clk>80 && clk>=0)
9190 {
9191 201020 int32_t wall=hero_on_wall();
9192 201020 int32_t wallm_cnt=0;
9193
9194
2/2
✓ Branch 0 taken 1527970 times.
✓ Branch 1 taken 201020 times.
1728990 for(int32_t i=0; i<guys.Count(); i++)
9195
2/2
✓ Branch 0 taken 541113 times.
✓ Branch 1 taken 986857 times.
2514827 if(((enemy*)guys.spr(i))->family==eeWALLM)
9196 {
9197 986857 int32_t m=((enemy*)guys.spr(i))->misc;
9198
9199
4/4
✓ Branch 0 taken 48466 times.
✓ Branch 1 taken 938391 times.
✓ Branch 2 taken 35102 times.
✓ Branch 3 taken 13364 times.
986857 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9200 {
9201 13364 ++wallm_cnt;
9202 13364 }
9203 986857 }
9204
9205
2/2
✓ Branch 0 taken 200189 times.
✓ Branch 1 taken 831 times.
201020 if(wall>0)
9206 {
9207 831 --wall;
9208 831 misc=1; //emerging from the wall?
9209 831 clk2=0;
9210 831 clk3=wall^1;
9211 831 wallm_load_clk=frame;
9212
9213
2/2
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 320 times.
831 if(wall<=down)
9214 {
9215
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 420 times.
511 if(HeroDir()==left)
9216 91 dir=right;
9217 else
9218 420 dir=left;
9219 511 }
9220 else
9221 {
9222
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 254 times.
320 if(HeroDir()==up)
9223 66 dir=down;
9224 else
9225 254 dir=up;
9226 }
9227
9228
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 216 times.
✓ Branch 4 taken 104 times.
831 switch(wall)
9229 {
9230 case up:
9231 231 y=0;
9232 231 break;
9233
9234 case down:
9235 280 y=160;
9236 280 break;
9237
9238 case left:
9239 216 x=0;
9240 216 break;
9241
9242 case right:
9243 104 x=240;
9244 104 break;
9245 }
9246
9247
9248
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 254 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 420 times.
✓ Branch 4 taken 91 times.
831 switch(dir)
9249 {
9250 case up:
9251 254 y=(HeroY()+48-(wallm_cnt&1)*12);
9252 254 flip=wall&1;
9253 254 break;
9254
9255 case down:
9256 66 y=(HeroY()-48+(wallm_cnt&1)*12);
9257 66 flip=((wall&1)^1)+2;
9258 66 break;
9259
9260 case left:
9261 420 x=(HeroX()+48-(wallm_cnt&1)*12);
9262 420 flip=(wall==up?2:0)+1;
9263 420 break;
9264
9265 case right:
9266 91 x=(HeroX()-48+(wallm_cnt&1)*12);
9267 91 flip=(wall==up?2:0);
9268 91 break;
9269 }
9270
9271 831 }
9272 201020 }
9273 365201 }
9274 else
9275 115663 wallm_crawl();
9276
9277 480864 return enemy::animate(index);
9278 490648 }
9279
9280 115663 void eWallM::wallm_crawl()
9281 {
9282 115663 bool w=watch;
9283 115663 hxofs=0;
9284
9285
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 114853 times.
115663 if(slide())
9286 {
9287 810 return;
9288 }
9289
9290 // if(dying || watch || (!hashero && stunclk))
9291
6/8
✓ Branch 0 taken 114853 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113726 times.
✓ Branch 3 taken 1127 times.
✓ Branch 4 taken 99180 times.
✓ Branch 5 taken 14546 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 99180 times.
114853 if(dying || (!hashero && ( stunclk || frozenclock )))
9292 {
9293 14546 return;
9294 }
9295
9296 100307 watch=false;
9297 100307 ++clk2;
9298 // Misc1: slightly different movement
9299 100307 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9300
9301 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100307 times.
100307 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9303
5/6
✓ Branch 0 taken 6217 times.
✓ Branch 1 taken 94090 times.
✓ Branch 2 taken 4491 times.
✓ Branch 3 taken 1726 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4491 times.
100307 if(w&&misc>=3&&misc<=5)
9304 {
9305 4491 --clk2;
9306 4491 }
9307
9308
4/4
✓ Branch 0 taken 38425 times.
✓ Branch 1 taken 52102 times.
✓ Branch 2 taken 9640 times.
✓ Branch 3 taken 140 times.
100307 switch(misc)
9309 {
9310 case 1:
9311 case 2:
9312 52102 zc_swap(dir,clk3);
9313 52102 move(step);
9314 52102 zc_swap(dir,clk3);
9315 52102 break;
9316
9317 case 3:
9318 case 4:
9319 case 5:
9320
2/2
✓ Branch 0 taken 4491 times.
✓ Branch 1 taken 33934 times.
38425 if(w)
9321 {
9322 4491 watch=w;
9323 4491 return;
9324 }
9325
9326 33934 move(step);
9327 33934 break;
9328
9329 case 6:
9330 case 7:
9331 9640 zc_swap(dir,clk3);
9332 9640 dir^=1;
9333 9640 move(step);
9334 9640 dir^=1;
9335 9640 zc_swap(dir,clk3);
9336 9640 break;
9337
9338 default:
9339 140 misc=0;
9340 140 break;
9341 }
9342
9343 95816 watch=w;
9344 115663 }
9345
9346 8 void eWallM::grabhero()
9347 {
9348 8 hashero=true;
9349 8 superman=1;
9350 8 }
9351
9352 492831 void eWallM::draw(BITMAP *dest)
9353 {
9354 492831 dummy_bool[1]=hashero;
9355 492831 update_enemy_frame();
9356
9357
4/6
✓ Branch 0 taken 365993 times.
✓ Branch 1 taken 126838 times.
✓ Branch 2 taken 365993 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 365993 times.
492831 if(misc>0 || fallclk||drownclk)
9358 {
9359 126838 masked_draw(dest,16,playing_field_offset+16,224,144);
9360 126838 }
9361
9362 // enemy::draw(dest);
9363 // tile = clk&8 ? 128:129;
9364 492831 }
9365
9366 bool eWallM::isSubmerged() const
9367 {
9368 return ( !misc );
9369 }
9370
9371 1616 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9372 1616 {
9373
1/2
✓ Branch 0 taken 1616 times.
✗ Branch 1 not taken.
1616 ox=x; //original x
9374
1/2
✓ Branch 0 taken 1616 times.
✗ Branch 1 not taken.
1616 oy=y; //original y
9375
2/2
✓ Branch 0 taken 1450 times.
✓ Branch 1 taken 166 times.
1616 if(get_qr(qr_TRAPPOSFIX))
9376 {
9377
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
166 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9378 166 }
9379
9380 1616 mainguy=false;
9381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1616 times.
1616 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9382 //nets+420;
9383 1616 dummy_int[1]=0;
9384
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1616 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1616 if (SIZEflags != 0) init_size_flags();;
9385 1616 }
9386
9387 988105 bool eTrap::animate(int32_t index)
9388 {
9389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988105 times.
988105 if(switch_hooked) return enemy::animate(index);
9390
2/4
✓ Branch 0 taken 988105 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 988105 times.
988105 if(fallclk||drownclk) return enemy::animate(index);
9391
2/2
✓ Branch 0 taken 966787 times.
✓ Branch 1 taken 21318 times.
988105 if(clk<0)
9392 21318 return enemy::animate(index);
9393
9394
2/2
✓ Branch 0 taken 905610 times.
✓ Branch 1 taken 61177 times.
966787 if(clk==0)
9395 {
9396 61177 removearmos(x,y,ffcactivated);
9397 61177 }
9398
9399
2/2
✓ Branch 0 taken 308686 times.
✓ Branch 1 taken 658101 times.
966787 if(misc==0) // waiting
9400 {
9401 658101 ox = x;
9402 658101 oy = y;
9403 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9404 658101 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9405
9406
4/4
✓ Branch 0 taken 221292 times.
✓ Branch 1 taken 436809 times.
✓ Branch 2 taken 122658 times.
✓ Branch 3 taken 98634 times.
658101 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9407 {
9408 98634 dir=down;
9409 98634 }
9410
4/4
✓ Branch 0 taken 372869 times.
✓ Branch 1 taken 186598 times.
✓ Branch 2 taken 122658 times.
✓ Branch 3 taken 250211 times.
559467 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9411 {
9412 250211 dir=right;
9413 250211 }
9414
4/4
✓ Branch 0 taken 198151 times.
✓ Branch 1 taken 111105 times.
✓ Branch 2 taken 122658 times.
✓ Branch 3 taken 75493 times.
309256 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9415 {
9416 75493 dir=up;
9417 75493 }
9418 else
9419 {
9420 233763 dir=left;
9421 }
9422
9423 658101 int32_t d2=lined_up(15,true);
9424
9425
4/4
✓ Branch 0 taken 250573 times.
✓ Branch 1 taken 407528 times.
✓ Branch 2 taken 1017391 times.
✓ Branch 3 taken 359290 times.
1023375 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9426
2/2
✓ Branch 0 taken 214396 times.
✓ Branch 1 taken 156098 times.
359290 ((d2>down) && (dmisc1==2)) ||
9427
2/2
✓ Branch 0 taken 172587 times.
✓ Branch 1 taken 61967 times.
156098 ((d2>right) && (!dmisc1)) ||
9428
2/2
✓ Branch 0 taken 365274 times.
✓ Branch 1 taken 130720 times.
234554 ((d2<l_up) && (dmisc1==4)) ||
9429
3/4
✓ Branch 0 taken 365274 times.
✓ Branch 1 taken 234554 times.
✓ Branch 2 taken 365274 times.
✗ Branch 3 not taken.
130720 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9430
3/4
✓ Branch 0 taken 365274 times.
✓ Branch 1 taken 130720 times.
✓ Branch 2 taken 365274 times.
✗ Branch 3 not taken.
234554 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9431 {
9432 2327609 d2=-1;
9433 2327609 }
9434
9435
4/4
✓ Branch 0 taken 15249 times.
✓ Branch 1 taken 408298 times.
✓ Branch 2 taken 13216 times.
✓ Branch 3 taken 2033 times.
423547 if(d2!=-1 && trapmove(d2))
9436 {
9437 2033 dir=d2;
9438 2033 misc=1;
9439 2033 clk2=(dir==down)?3:0;
9440 2033 }
9441 423547 }
9442
9443
2/2
✓ Branch 0 taken 645337 times.
✓ Branch 1 taken 86896 times.
732233 if(misc==1) // charging
9444 {
9445 86896 clk2=(clk2+1)&3;
9446 86896 step=(clk2==3)?1:2;
9447
9448
4/4
✓ Branch 0 taken 86092 times.
✓ Branch 1 taken 804 times.
✓ Branch 2 taken 1028 times.
✓ Branch 3 taken 85064 times.
86896 if(!trapmove(dir) || clip())
9449 {
9450 1832 misc=2;
9451
9452
1/2
✓ Branch 0 taken 1832 times.
✗ Branch 1 not taken.
1832 if(dir<l_up)
9453 {
9454 1832 dir=dir^1;
9455 1832 }
9456 else
9457 {
9458 dir=dir^3;
9459 }
9460 1832 }
9461 else
9462 {
9463 85064 sprite::move(step);
9464 }
9465 86896 }
9466
9467
2/2
✓ Branch 0 taken 506578 times.
✓ Branch 1 taken 225655 times.
732233 if(misc==2) // retreating
9468 {
9469 225655 step=(++clk2&1)?1:0;
9470
9471
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 37653 times.
✓ Branch 2 taken 79537 times.
✓ Branch 3 taken 27939 times.
✓ Branch 4 taken 80526 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
225655 switch(dir)
9472 {
9473 case up:
9474
2/2
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 37395 times.
37653 if(int32_t(y)<=oy) goto trap_rest;
9475 37395 else sprite::move(step);
9476
9477 37395 break;
9478
9479 case left:
9480
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 79155 times.
79537 if(int32_t(x)<=ox) goto trap_rest;
9481 79155 else sprite::move(step);
9482
9483 79155 break;
9484
9485 case down:
9486
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 27729 times.
27939 if(int32_t(y)>=oy) goto trap_rest;
9487 27729 else sprite::move(step);
9488
9489 27729 break;
9490
9491 case right:
9492
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 80126 times.
80526 if(int32_t(x)>=ox) goto trap_rest;
9493 80126 else sprite::move(step);
9494
9495 80126 break;
9496
9497 case l_up:
9498 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9499 else sprite::move(step);
9500
9501 break;
9502
9503 case r_up:
9504 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9505 else sprite::move(step);
9506
9507 break;
9508
9509 case l_down:
9510 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9511 else sprite::move(step);
9512
9513 break;
9514
9515 case r_down:
9516 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9517 else sprite::move(step);
9518
9519 break;
9520 trap_rest:
9521 {
9522 1250 x=ox;
9523 1250 y=oy;
9524 1250 misc=0;
9525 }
9526 1250 }
9527 225655 }
9528
9529 732233 return enemy::animate(index);
9530 753551 }
9531
9532 102145 bool eTrap::trapmove(int32_t ndir)
9533 {
9534
2/2
✓ Branch 0 taken 80479 times.
✓ Branch 1 taken 21666 times.
102145 if(get_qr(qr_MEANTRAPS))
9535 {
9536 80479 mapscr* scr = get_scr(screen_spawned);
9537
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 79139 times.
80479 if(scr->flags2&fFLOATTRAPS)
9538 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9539
9540 79139 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9541 }
9542
9543
6/6
✓ Branch 0 taken 8168 times.
✓ Branch 1 taken 13498 times.
✓ Branch 2 taken 5093 times.
✓ Branch 3 taken 3075 times.
✓ Branch 4 taken 2106 times.
✓ Branch 5 taken 2987 times.
21666 if(oy==80 && !(ndir==left || ndir == right))
9544 2987 return false;
9545
9546
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18679 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18679 if(ox==128 && !(ndir==up || ndir==down))
9547 return false;
9548
9549
3/4
✓ Branch 0 taken 7071 times.
✓ Branch 1 taken 11608 times.
✓ Branch 2 taken 7071 times.
✗ Branch 3 not taken.
18679 if(oy<80 && ndir==up)
9550 return false;
9551
9552
3/4
✓ Branch 0 taken 6427 times.
✓ Branch 1 taken 12252 times.
✓ Branch 2 taken 6427 times.
✗ Branch 3 not taken.
18679 if(oy>80 && ndir==down)
9553 return false;
9554
9555
4/4
✓ Branch 0 taken 9686 times.
✓ Branch 1 taken 8993 times.
✓ Branch 2 taken 8403 times.
✓ Branch 3 taken 1283 times.
18679 if(ox<128 && ndir==left)
9556 1283 return false;
9557
9558
4/4
✓ Branch 0 taken 8993 times.
✓ Branch 1 taken 8403 times.
✓ Branch 2 taken 8475 times.
✓ Branch 3 taken 518 times.
17396 if(ox>128 && ndir==right)
9559 518 return false;
9560
9561
5/6
✓ Branch 0 taken 8403 times.
✓ Branch 1 taken 8475 times.
✓ Branch 2 taken 3661 times.
✓ Branch 3 taken 4742 times.
✓ Branch 4 taken 3661 times.
✗ Branch 5 not taken.
16878 if(ox<128 && oy<80 && ndir==l_up)
9562 return false;
9563
9564
5/6
✓ Branch 0 taken 8403 times.
✓ Branch 1 taken 8475 times.
✓ Branch 2 taken 3154 times.
✓ Branch 3 taken 5249 times.
✓ Branch 4 taken 3154 times.
✗ Branch 5 not taken.
16878 if(ox<128 && oy>80 && ndir==l_down)
9565 return false;
9566
9567
5/6
✓ Branch 0 taken 8475 times.
✓ Branch 1 taken 8403 times.
✓ Branch 2 taken 3410 times.
✓ Branch 3 taken 5065 times.
✓ Branch 4 taken 3410 times.
✗ Branch 5 not taken.
16878 if(ox>128 && oy<80 && ndir==r_up)
9568 return false;
9569
9570
5/6
✓ Branch 0 taken 8475 times.
✓ Branch 1 taken 8403 times.
✓ Branch 2 taken 3273 times.
✓ Branch 3 taken 5202 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3273 times.
16878 if(ox>128 && oy>80 && ndir==r_down)
9571 return false;
9572
9573 16878 return true;
9574 102145 }
9575
9576 86092 bool eTrap::clip()
9577 {
9578
2/2
✓ Branch 0 taken 40383 times.
✓ Branch 1 taken 45709 times.
86092 if(get_qr(qr_MEANPLACEDTRAPS))
9579 {
9580
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
✓ Branch 2 taken 8656 times.
✓ Branch 3 taken 16039 times.
✓ Branch 4 taken 15222 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
45709 switch(dir)
9581 {
9582 case up:
9583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5792 times.
5792 if(y<=0) return true;
9584
9585 5792 break;
9586
9587 case down:
9588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8656 times.
8656 if(y>=world_h-16) return true;
9589
9590 8656 break;
9591
9592 case left:
9593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16039 times.
16039 if(x<=0) return true;
9594
9595 16039 break;
9596
9597 case right:
9598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15222 times.
15222 if(x>=world_w-16) return true;
9599
9600 15222 break;
9601
9602 case l_up:
9603 if(y<=0||x<=0) return true;
9604
9605 break;
9606
9607 case l_down:
9608 if(y>=world_h-16||x<=0) return true;
9609
9610 break;
9611
9612 case r_up:
9613 if(y<=0||x>=world_w-16) return true;
9614
9615 break;
9616
9617 case r_down:
9618 if(y>=world_h-16||x>=world_w-16) return true;
9619
9620 break;
9621 }
9622
9623 45709 return false;
9624 }
9625 else
9626 {
9627
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 4514 times.
✓ Branch 2 taken 5039 times.
✓ Branch 3 taken 15440 times.
✓ Branch 4 taken 15390 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
40383 switch(dir)
9628 {
9629 case up:
9630
4/4
✓ Branch 0 taken 4460 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 4287 times.
✓ Branch 3 taken 173 times.
4514 if(oy>80 && y<=86) return true;
9631
9632 4341 break;
9633
9634 case down:
9635
4/4
✓ Branch 0 taken 4958 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 4776 times.
✓ Branch 3 taken 182 times.
5039 if(oy<80 && y>=80) return true;
9636
9637 4857 break;
9638
9639 case left:
9640
4/4
✓ Branch 0 taken 15350 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 15008 times.
✓ Branch 3 taken 342 times.
15440 if(ox>128 && x<=124) return true;
9641
9642 15098 break;
9643
9644 case right:
9645
4/4
✓ Branch 0 taken 15309 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 14978 times.
✓ Branch 3 taken 331 times.
15390 if(ox<120 && x>=116) return true;
9646
9647 15059 break;
9648
9649 case l_up:
9650 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9651
9652 break;
9653
9654 case l_down:
9655 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9656
9657 break;
9658
9659 case r_up:
9660 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9661
9662 break;
9663
9664 case r_down:
9665 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9666
9667 break;
9668 }
9669
9670 39355 return false;
9671 }
9672 86092 }
9673
9674 1007019 void eTrap::draw(BITMAP *dest)
9675 {
9676 1007019 update_enemy_frame();
9677 1007019 enemy::draw(dest);
9678 1007019 }
9679
9680 5523 int32_t eTrap::takehit(weapon*,weapon*)
9681 {
9682 5523 return 0;
9683 }
9684
9685 832 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9686 832 {
9687 832 lasthit=-1;
9688 832 lasthitclk=0;
9689 832 mainguy=false;
9690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
832 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9691
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 step=2;
9692
3/6
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 399 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
832 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9693 {
9694
2/4
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
399 dir=(x<=112)?right:left;
9695 399 }
9696 else
9697 {
9698
2/4
✓ Branch 0 taken 433 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
433 dir=(y<=72)?down:up;
9699 }
9700
9701
2/2
✓ Branch 0 taken 760 times.
✓ Branch 1 taken 72 times.
832 if(get_qr(qr_TRAPPOSFIX))
9702 {
9703
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9704 72 }
9705
9706 //nets+((id==eTRAP_LR)?540:520);
9707 832 dummy_int[1]=0;
9708
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
832 if (SIZEflags != 0) init_size_flags();;
9709 832 }
9710
9711 346559 bool eTrap2::animate(int32_t index)
9712 {
9713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 346559 times.
346559 if(switch_hooked) return enemy::animate(index);
9714
2/4
✓ Branch 0 taken 346559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 346559 times.
346559 if(fallclk||drownclk) return enemy::animate(index);
9715
2/2
✓ Branch 0 taken 335533 times.
✓ Branch 1 taken 11026 times.
346559 if(clk<0)
9716 11026 return enemy::animate(index);
9717
9718
2/2
✓ Branch 0 taken 21385 times.
✓ Branch 1 taken 314148 times.
335533 if(clk==0)
9719 {
9720 21385 removearmos(x,y,ffcactivated);
9721 21385 }
9722
9723
2/2
✓ Branch 0 taken 211207 times.
✓ Branch 1 taken 124326 times.
335533 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9724 {
9725
2/2
✓ Branch 0 taken 11074 times.
✓ Branch 1 taken 113252 times.
124326 if(lasthitclk>0)
9726 {
9727 11074 --lasthitclk;
9728 11074 }
9729 else
9730 {
9731 113252 lasthit=-1;
9732 }
9733
9734 124326 bool hitenemy=false;
9735
9736
2/2
✓ Branch 0 taken 864860 times.
✓ Branch 1 taken 124326 times.
989186 for(int32_t j=0; j<guys.Count(); j++)
9737 {
9738
4/4
✓ Branch 0 taken 740534 times.
✓ Branch 1 taken 124326 times.
✓ Branch 2 taken 10183 times.
✓ Branch 3 taken 730351 times.
864860 if((j!=index) && (lasthit!=j))
9739 {
9740
2/2
✓ Branch 0 taken 726682 times.
✓ Branch 1 taken 3669 times.
730351 if(hit(guys.spr(j)))
9741 {
9742 3669 lasthit=j;
9743 3669 lasthitclk=10;
9744 3669 hitenemy=true;
9745 3669 guys.spr(j)->lasthit=index;
9746 3669 guys.spr(j)->lasthitclk=10;
9747 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9748 3669 }
9749 730351 }
9750 864860 }
9751
9752
5/6
✓ Branch 0 taken 121171 times.
✓ Branch 1 taken 3155 times.
✓ Branch 2 taken 121171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2831 times.
✓ Branch 5 taken 118340 times.
124326 if(!trapmove(dir) || clip() || hitenemy)
9753 {
9754
3/4
✓ Branch 0 taken 2831 times.
✓ Branch 1 taken 3155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2831 times.
5986 if(!trapmove(dir) || clip())
9755 {
9756 3155 lasthit=-1;
9757 3155 lasthitclk=0;
9758 3155 }
9759
9760
2/2
✓ Branch 0 taken 5624 times.
✓ Branch 1 taken 362 times.
5986 if(get_qr(qr_MORESOUNDS))
9761 362 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9762
9763 5986 dir=dir^1;
9764 5986 }
9765
9766 124326 sprite::move(step);
9767 124326 }
9768 else
9769 {
9770
3/4
✓ Branch 0 taken 204288 times.
✓ Branch 1 taken 6919 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 204288 times.
211207 if(!trapmove(dir) || clip())
9771 {
9772
2/2
✓ Branch 0 taken 5398 times.
✓ Branch 1 taken 1521 times.
6919 if(get_qr(qr_MORESOUNDS))
9773 1521 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9774
9775 6919 dir=dir^1;
9776 6919 }
9777
9778 211207 sprite::move(step);
9779 }
9780
9781 335533 return enemy::animate(index);
9782 346559 }
9783
9784 341519 bool eTrap2::trapmove(int32_t ndir)
9785 {
9786 341519 mapscr* scr = get_scr(screen_spawned);
9787
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 339641 times.
341519 if(scr->flags2&fFLOATTRAPS)
9788 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9789
9790 339641 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9791 341519 }
9792
9793 328290 bool eTrap2::clip()
9794 {
9795
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 88320 times.
✓ Branch 2 taken 89029 times.
✓ Branch 3 taken 75153 times.
✓ Branch 4 taken 75788 times.
328290 switch(dir)
9796 {
9797 case up:
9798
1/2
✓ Branch 0 taken 88320 times.
✗ Branch 1 not taken.
88320 if(y<=0) return true;
9799
9800 88320 break;
9801
9802 case down:
9803
1/2
✓ Branch 0 taken 89029 times.
✗ Branch 1 not taken.
89029 if(y>=world_h-16) return true;
9804
9805 89029 break;
9806
9807 case left:
9808
1/2
✓ Branch 0 taken 75153 times.
✗ Branch 1 not taken.
75153 if(x<=0) return true;
9809
9810 75153 break;
9811
9812 case right:
9813
1/2
✓ Branch 0 taken 75788 times.
✗ Branch 1 not taken.
75788 if(x>=world_w-16) return true;
9814
9815 75788 break;
9816 }
9817
9818 328290 return false;
9819 328290 }
9820
9821 350933 void eTrap2::draw(BITMAP *dest)
9822 {
9823 350933 update_enemy_frame();
9824 350933 enemy::draw(dest);
9825 350933 }
9826
9827 3169 int32_t eTrap2::takehit(weapon*,weapon*)
9828 {
9829 3169 return 0;
9830 }
9831
9832 354 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9833 354 {
9834 //do not show "enemy appering" anim -DD
9835 354 clk=0;
9836 354 mainguy=false;
9837 354 clk2=-14;
9838 //Enemy Editor Size Tab
9839
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 init_size_flags();
9840 //nets+1640;
9841 354 }
9842
9843 354 void eRock::init_size_flags()
9844 {
9845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
9846 354 else hxofs = -2;
9847
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
354 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
9848 354 else hyofs = -2;
9849
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
9850 354 else hit_width = 20;
9851
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
9852 354 else hit_height = 20;
9853
9854
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9855
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
354 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
9856
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
354 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
9857
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
9858
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
9859 {
9860 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9861 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
9862 }
9863
9864
1/2
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
354 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
9865 354 }
9866
9867 121997 bool eRock::animate(int32_t index)
9868 {
9869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(switch_hooked) return enemy::animate(index);
9870
2/4
✓ Branch 0 taken 121997 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121997 times.
121997 if(fallclk||drownclk) return enemy::animate(index);
9871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121997 times.
121997 if(dying)
9872 return Dead(index);
9873
9874
2/2
✓ Branch 0 taken 113621 times.
✓ Branch 1 taken 8376 times.
121997 if(clk==0)
9875 {
9876 8376 removearmos(x,y,ffcactivated);
9877 8376 }
9878
9879
2/2
✓ Branch 0 taken 121300 times.
✓ Branch 1 taken 697 times.
121997 if(++clk2==0) // start it
9880 {
9881 697 x=zc_oldrand()&0xF0;
9882 697 y=0;
9883 697 clk3=0;
9884 697 clk2=zc_oldrand()&15;
9885 697 }
9886
9887
2/2
✓ Branch 0 taken 22820 times.
✓ Branch 1 taken 99177 times.
121997 if(clk2>16) // move it
9888 {
9889
2/2
✓ Branch 0 taken 95747 times.
✓ Branch 1 taken 3430 times.
99177 if(clk3<=0) // start bounce
9890 {
9891 3430 dir=zc_oldrand()&1;
9892
9893
2/2
✓ Branch 0 taken 3063 times.
✓ Branch 1 taken 367 times.
3430 if(x<32) dir=1;
9894
9895
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 297 times.
3430 if(x>208) dir=0;
9896 3430 }
9897
9898
2/2
✓ Branch 0 taken 95993 times.
✓ Branch 1 taken 3184 times.
99177 if(clk3<13+16)
9899 {
9900 95993 x += dir ? 1 : -1; //right, left
9901 95993 dummy_int[1]=dir;
9902
9903
2/2
✓ Branch 0 taken 6852 times.
✓ Branch 1 taken 89141 times.
95993 if(clk3<2)
9904 {
9905 6852 y-=2; //up
9906 6852 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9907 6852 }
9908
2/2
✓ Branch 0 taken 10208 times.
✓ Branch 1 taken 78933 times.
89141 else if(clk3<5)
9909 {
9910 10208 y--; //up
9911 10208 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
9912 10208 }
9913
2/2
✓ Branch 0 taken 10135 times.
✓ Branch 1 taken 68798 times.
78933 else if(clk3<8)
9914 {
9915 10135 dummy_int[2]=(dummy_int[1]==1)?right:left;
9916 10135 }
9917
2/2
✓ Branch 0 taken 10058 times.
✓ Branch 1 taken 58740 times.
68798 else if(clk3<11)
9918 {
9919 10058 y++; //down
9920 10058 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9921 10058 }
9922 else
9923 {
9924 58740 y+=2; //down
9925 58740 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
9926 }
9927
9928 95993 ++clk3;
9929 95993 }
9930
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 423 times.
3184 else if(y<world_h)
9931 2761 clk3=0; // next bounce
9932 else
9933 423 clk2 = -(zc_oldrand()&63); // back to top
9934 99177 }
9935
9936 121997 return enemy::animate(index);
9937 121997 }
9938
9939 51441 void eRock::drawshadow(BITMAP *dest, bool translucent)
9940 {
9941
2/2
✓ Branch 0 taken 7191 times.
✓ Branch 1 taken 44250 times.
51441 if(clk2>=0)
9942 {
9943 44250 int32_t tempy=yofs;
9944 44250 flip = 0;
9945 44250 int32_t fdiv = frate/4;
9946
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
9947
1/2
✓ Branch 0 taken 44250 times.
✗ Branch 1 not taken.
44250 int32_t f2=get_qr(qr_NEWENEMYTILES)?
9948 44250 efrate:((clk>=(frate>>1))?1:0);
9949 44250 shadowtile = wpnsbuf[spr_shadow].tile+f2;
9950
9951 44250 yofs+=8;
9952
6/6
✓ Branch 0 taken 20474 times.
✓ Branch 1 taken 23776 times.
✓ Branch 2 taken 38962 times.
✓ Branch 3 taken 5288 times.
✓ Branch 4 taken 19073 times.
✓ Branch 5 taken 19889 times.
44250 yofs+=zc_max(0,zc_min(29-clk3,clk3));
9953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44250 times.
44250 if(!shadow_overpit(this))
9954 44250 sprite::drawshadow(dest, translucent);
9955 44250 yofs=tempy;
9956 44250 }
9957 51441 }
9958
9959 122078 void eRock::draw(BITMAP *dest)
9960 {
9961
4/6
✓ Branch 0 taken 17035 times.
✓ Branch 1 taken 105043 times.
✓ Branch 2 taken 17035 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 17035 times.
122078 if(clk2>=0 || fallclk||drownclk)
9962 {
9963 105043 int32_t tempdir=dir;
9964 105043 dir=dummy_int[2];
9965 105043 update_enemy_frame();
9966 105043 enemy::draw(dest);
9967 105043 dir=tempdir;
9968 105043 }
9969 122078 }
9970
9971 1014 int32_t eRock::takehit(weapon*,weapon*)
9972 {
9973 1014 return 0;
9974 }
9975
9976 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9977 30 {
9978 30 clk=0;
9979 30 mainguy=false;
9980 30 clk2=-14;
9981
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 init_size_flags();
9982 //nets+1680;
9983 30 }
9984
9985 4440 bool eBoulder::animate(int32_t index)
9986 {
9987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
9988
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
9989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
9990 return Dead(index);
9991
9992
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
9993 {
9994 290 removearmos(x,y,ffcactivated);
9995 290 }
9996
9997 zfix *vert;
9998
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & move_use_fake_z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
9999
10000
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
10001 {
10002 32 x=zc_oldrand()&0xF0;
10003 32 y=-32;
10004 32 clk3=0;
10005 32 clk2=zc_oldrand()&15;
10006 32 }
10007
10008
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10009 {
10010
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10011 {
10012 131 dir=zc_oldrand()&1;
10013
10014
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10015
10016
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10017 131 }
10018
10019
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10020 {
10021 3487 x += dir ? 1 : -1; //right, left
10022 3487 dummy_int[1]=dir;
10023
10024
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10025 {
10026 261 y-=2; //up
10027 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10028 261 }
10029
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10030 {
10031 382 y--; //up
10032 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10033 382 }
10034
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10035 {
10036 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10037 376 }
10038
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10039 {
10040 367 y++; //down
10041 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10042 367 }
10043 else
10044 {
10045 2101 y+=2; //down
10046 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10047 }
10048
10049 3487 ++clk3;
10050 3487 }
10051
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10052 101 clk3=0; // next bounce
10053 else
10054 10 clk2 = -(zc_oldrand()&63); // back to top
10055 3598 }
10056
10057 4440 return enemy::animate(index);
10058 4440 }
10059
10060 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10061 {
10062
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10063 {
10064 3868 int32_t tempy=yofs;
10065 3868 flip = 0;
10066 3868 int32_t f2=((clk<<2)/frate)<<1;
10067 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10068
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10069
10070 3868 yofs+=8;
10071 3868 xofs-=8;
10072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10073 3868 sprite::drawshadow(dest, translucent);
10074 3868 xofs+=16;
10075 3868 ++shadowtile;
10076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10077 3868 sprite::drawshadow(dest, translucent);
10078 3868 yofs+=16;
10079 3868 shadowtile+=20;
10080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10081 3868 sprite::drawshadow(dest, translucent);
10082 3868 xofs-=16;
10083 3868 --shadowtile;
10084
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10085 3868 sprite::drawshadow(dest, translucent);
10086 3868 xofs+=8;
10087 3868 yofs=tempy;
10088 3868 }
10089 4440 }
10090
10091 4440 void eBoulder::draw(BITMAP *dest)
10092 {
10093
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10094 {
10095 3868 int32_t tempdir=dir;
10096 3868 dir=dummy_int[2];
10097 3868 update_enemy_frame();
10098 3868 dir=tempdir;
10099 3868 xofs-=8;
10100 3868 yofs-=8;
10101 3868 drawblock(dest,15);
10102 3868 xofs+=8;
10103 3868 yofs+=8;
10104 // enemy::draw(dest);
10105 3868 }
10106 4440 }
10107
10108 30 void eBoulder::init_size_flags()
10109 {
10110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
10111 30 else hxofs = -10;
10112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ((d->SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
10113 30 else hyofs = -10;
10114
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10115 30 else hit_width = 36;
10116
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
10117 30 else hit_height = 36;
10118
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
10119 30 else hzsz = 16; //can't be jumped
10120
10121
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10122
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if (((d->SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
10123
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if (((d->SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
10124
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
10125
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
10126 {
10127 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10128 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
10129 }
10130
10131
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if ((d->SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
10132 30 }
10133
10134 int32_t eBoulder::takehit(weapon*,weapon*)
10135 {
10136 return 0;
10137 }
10138
10139 4429 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10140
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 3898 times.
4429 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10141 4429 {
10142 /* fixing
10143 hp=1;
10144 */
10145 4429 mainguy=false;
10146
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 4422 times.
4429 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10147 4429 hclk=clk; // the "no fire" range
10148 4429 clk=0;
10149 4429 clk3=96;
10150 4429 timer=0;
10151
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 4415 times.
4429 if(o_tile==0)
10152 {
10153 4415 superman=1;
10154 4415 hxofs=1000;
10155 4415 }
10156
1/4
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4429 if (SIZEflags != 0) init_size_flags();;
10157 4429 }
10158
10159 2504746 bool eProjectile::animate(int32_t index)
10160 {
10161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2504746 times.
2504746 if(switch_hooked) return enemy::animate(index);
10162
2/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2504746 times.
2504746 if(fallclk||drownclk) return enemy::animate(index);
10163
2/2
✓ Branch 0 taken 2492420 times.
✓ Branch 1 taken 12326 times.
2504746 if(clk==0)
10164 {
10165 12326 removearmos(x,y,ffcactivated);
10166 12326 }
10167
10168 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10169 2504746 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10170
10171
4/4
✓ Branch 0 taken 835608 times.
✓ Branch 1 taken 1669138 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 403631 times.
2504746 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10172 {
10173 403631 dir=down;
10174 403631 }
10175
4/4
✓ Branch 0 taken 1348897 times.
✓ Branch 1 taken 752218 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 916920 times.
2101115 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10176 {
10177 916920 dir=right;
10178 916920 }
10179
4/4
✓ Branch 0 taken 790877 times.
✓ Branch 1 taken 393318 times.
✓ Branch 2 taken 431977 times.
✓ Branch 3 taken 358900 times.
1184195 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10180 {
10181 358900 dir=up;
10182 358900 }
10183 else
10184 {
10185 825295 dir=left;
10186 }
10187
10188
3/4
✓ Branch 0 taken 2504746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1306267 times.
✓ Branch 3 taken 1198479 times.
2504746 if(!stunclk && ++clk3>80)
10189 {
10190
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 1197433 times.
1198479 if(dmisc1==9) // Breath type
10191 {
10192
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 563 times.
1046 if(timer==0)
10193 {
10194 563 unsigned r=zc_oldrand();
10195
10196
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 557 times.
563 if(!(r&63))
10197 {
10198 6 timer=zc_oldrand()%50+50;
10199 6 }
10200 563 }
10201
10202
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 489 times.
1046 if(timer>0)
10203 {
10204
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 119 times.
489 if(timer%4==0)
10205 {
10206 119 FireBreath(false);
10207 119 }
10208
10209
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 6 times.
489 if(--timer==0)
10210 {
10211 6 clk3=0;
10212 6 }
10213 489 }
10214 1046 }
10215
10216 else // Not breath type
10217 {
10218 1197433 unsigned r=zc_oldrand();
10219
10220
4/4
✓ Branch 0 taken 18808 times.
✓ Branch 1 taken 1178625 times.
✓ Branch 2 taken 1266 times.
✓ Branch 3 taken 17542 times.
1197433 if(!(r&63) && !HeroInRange(minRange))
10221 {
10222 17542 FireWeapon();
10223
10224
4/4
✓ Branch 0 taken 15040 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 66 times.
17794 if(get_qr(qr_BROKENSTATUES)==0 &&
10225
3/4
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14788 times.
✓ Branch 2 taken 252 times.
✗ Branch 3 not taken.
15040 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10226 {
10227
2/2
✓ Branch 0 taken 13945 times.
✓ Branch 1 taken 909 times.
14854 if(!((r>>7)&15))
10228 {
10229 909 x-=4;
10230 909 FireWeapon();
10231 909 x+=4;
10232 909 }
10233 14854 }
10234
10235 17542 clk3=0;
10236 17542 }
10237 }
10238 1198479 }
10239
10240 2504746 return enemy::animate(index);
10241 2504746 }
10242
10243 2520335 void eProjectile::draw(BITMAP *dest)
10244 {
10245 2520335 update_enemy_frame();
10246 2520335 enemy::draw(dest);
10247 2520335 }
10248
10249 533 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10250 533 {
10251 533 hxofs=1000;
10252 533 }
10253
10254 249811 void eTrigger::draw(BITMAP *dest)
10255 {
10256 249811 update_enemy_frame();
10257 249811 enemy::draw(dest);
10258 249811 }
10259
10260 void eTrigger::death_sfx()
10261 {
10262 //silent death
10263 }
10264
10265 5 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10266 5 {
10267 5 o_tile+=wpnsbuf[iwNPCs].tile;
10268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10269 5 SIZEflags = d->SIZEflags;
10270
1/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (SIZEflags != 0) init_size_flags();;
10271 5 }
10272
10273 75 bool eNPC::animate(int32_t index)
10274 {
10275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(switch_hooked) return enemy::animate(index);
10276
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 5 times.
75 if(dying)
10277 70 return Dead(index);
10278
10279
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(clk==0)
10280 {
10281 removearmos(x,y,ffcactivated);
10282 }
10283
10284
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 switch(dmisc2)
10285 {
10286 case 0:
10287 {
10288 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10289 5 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10290
10291
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10292 {
10293 dir=down;
10294 }
10295
10296
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10297 {
10298 5 dir=right;
10299 5 }
10300 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10301 {
10302 dir=up;
10303 }
10304 else
10305 {
10306 dir=left;
10307 }
10308 }
10309 5 break;
10310
10311 case 1:
10312 halting_walk(rate, homing, 0, hrate, 48);
10313
10314 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10315 {
10316 newdir(rate, homing, 0);
10317 clk2=48;
10318 ++misc;
10319 }
10320
10321 if(clk2==0)
10322 misc=0;
10323
10324 break;
10325 }
10326
10327 5 return enemy::animate(index);
10328 75 }
10329
10330 75 void eNPC::draw(BITMAP *dest)
10331 {
10332 75 update_enemy_frame();
10333 75 enemy::draw(dest);
10334 75 }
10335
10336 int32_t eNPC::takehit(weapon*,weapon*)
10337 {
10338 return 0;
10339 }
10340
10341 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10342 94 {
10343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10344 {
10345 94 o_tile=clk;
10346 94 cs=id>>12;
10347 94 }
10348
10349 94 id=id&0xFFF;
10350 94 clk=0;
10351
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10352 94 mainguy=false;
10353 94 SIZEflags = d->SIZEflags;
10354
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if (SIZEflags != 0) init_size_flags();;
10355 94 }
10356
10357 81 void eSpinTile::facehero()
10358 {
10359
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10360 {
10361
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10362 1 dir = up;
10363 else
10364 dir = down;
10365 1 }
10366 else
10367 {
10368 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10369 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10370
10371
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10372 {
10373 12 dir=l_down;
10374 12 }
10375
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10376 {
10377 1 dir=down;
10378 1 }
10379
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10380 {
10381 12 dir=r_down;
10382 12 }
10383
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10384 {
10385 6 dir=right;
10386 6 }
10387
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10388 {
10389 17 dir=r_up;
10390 17 }
10391
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10392 {
10393 8 dir=up;
10394 8 }
10395
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10396 {
10397 6 dir=l_up;
10398 6 }
10399 else
10400 {
10401 18 dir=left;
10402 }
10403 }
10404 81 }
10405
10406
10407 15539 bool eSpinTile::animate(int32_t index)
10408 {
10409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10410
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10411
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10412 {
10413 1152 return Dead(index);
10414 }
10415
10416
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10417 {
10418 1241 removearmos(x,y,ffcactivated);
10419 1241 }
10420
10421 14387 ++misc;
10422
10423
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10424 {
10425 81 facehero();
10426 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10427 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10428 81 angular=true;
10429 81 angle=ddir;
10430 81 step=zslongToFix(dstep*100);
10431 81 }
10432
10433
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10434 52 kickbucket();
10435
10436 14387 sprite::move(step);
10437 14387 return enemy::animate(index);
10438 15539 }
10439
10440 15457 void eSpinTile::draw(BITMAP *dest)
10441 {
10442 15457 update_enemy_frame();
10443 15457 y-=(misc>>4);
10444 15457 yofs+=2;
10445 15457 enemy::draw(dest);
10446 15457 yofs-=2;
10447 15457 y+=(misc>>4);
10448 15457 }
10449
10450 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10451 {
10452 15457 flip = 0;
10453 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10454 15457 yofs+=4;
10455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10456 15457 enemy::drawshadow(dest, translucent);
10457 15457 yofs-=4;
10458 15457 }
10459
10460 2797 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10461 2797 {
10462 //these are here to bypass compiler warnings about unused arguments
10463 2797 Clk=Clk;
10464 2797 mainguy=false;
10465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2797 times.
2797 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10466
1/4
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2797 if (SIZEflags != 0) init_size_flags();;
10467 2797 }
10468
10469 628398 void eZora::facehero()
10470 {
10471
2/2
✓ Branch 0 taken 10785 times.
✓ Branch 1 taken 617613 times.
628398 if(Hero.x-x==0)
10472 {
10473 10785 dir=(Hero.y+8<y)?up:down;
10474 10785 }
10475 else
10476 {
10477 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10478 617613 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10479
10480
4/4
✓ Branch 0 taken 125430 times.
✓ Branch 1 taken 492183 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 78554 times.
617613 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10481 {
10482 78554 dir=l_down;
10483 78554 }
10484
4/4
✓ Branch 0 taken 91951 times.
✓ Branch 1 taken 447108 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 45075 times.
539059 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10485 {
10486 45075 dir=down;
10487 45075 }
10488
4/4
✓ Branch 0 taken 121090 times.
✓ Branch 1 taken 372894 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 74214 times.
493984 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10489 {
10490 74214 dir=r_down;
10491 74214 }
10492
4/4
✓ Branch 0 taken 162238 times.
✓ Branch 1 taken 257532 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 115362 times.
419770 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10493 {
10494 115362 dir=right;
10495 115362 }
10496
4/4
✓ Branch 0 taken 127279 times.
✓ Branch 1 taken 177129 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 80403 times.
304408 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10497 {
10498 80403 dir=r_up;
10499 80403 }
10500
4/4
✓ Branch 0 taken 88819 times.
✓ Branch 1 taken 135186 times.
✓ Branch 2 taken 46876 times.
✓ Branch 3 taken 41943 times.
224005 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10501 {
10502 41943 dir=up;
10503 41943 }
10504
4/4
✓ Branch 0 taken 121548 times.
✓ Branch 1 taken 60514 times.
✓ Branch 2 taken 74672 times.
✓ Branch 3 taken 46876 times.
182062 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10505 {
10506 74672 dir=l_up;
10507 74672 }
10508 else
10509 {
10510 107390 dir=left;
10511 }
10512 }
10513 628398 }
10514
10515 857137 bool eZora::animate(int32_t index)
10516 {
10517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 857137 times.
857137 if(switch_hooked) return enemy::animate(index);
10518
2/2
✓ Branch 0 taken 2854 times.
✓ Branch 1 taken 854283 times.
857137 if(dying)
10519 2854 return Dead(index);
10520
10521
2/2
✓ Branch 0 taken 848537 times.
✓ Branch 1 taken 5746 times.
854283 if(clk==0)
10522 {
10523 5746 removearmos(x,y,ffcactivated);
10524 5746 }
10525
10526
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 854248 times.
854283 if(watch)
10527 {
10528 35 clock_zoras.push_back({screen_spawned, id});
10529 35 return true;
10530 }
10531
10532
2/2
✓ Branch 0 taken 225850 times.
✓ Branch 1 taken 628398 times.
854248 if(get_qr(qr_NEWENEMYTILES))
10533 {
10534 628398 facehero();
10535 628398 }
10536
10537
6/6
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 4993 times.
✓ Branch 2 taken 4190 times.
✓ Branch 3 taken 830374 times.
✓ Branch 4 taken 6482 times.
✓ Branch 5 taken 2977 times.
854248 switch(clk)
10538 {
10539 case 0: // reposition him
10540 {
10541 6482 int32_t t=0;
10542 6482 int32_t pos2=zc_oldrand()%160 + 16;
10543 6482 bool placed=false;
10544
10545
4/4
✓ Branch 0 taken 6417 times.
✓ Branch 1 taken 38529 times.
✓ Branch 2 taken 26366 times.
✓ Branch 3 taken 5746 times.
44946 while(!placed && t<160)
10546 {
10547 26366 rpos_t rpos = POS_TO_RPOS(pos2, screen_spawned);
10548 90460 auto [sx, sy] = COMBOXY_REGION(rpos);
10549 26366 mapscr* s = get_scr(screen_spawned);
10550
10551 79098 int32_t watertype = iswaterex_z3(s->data[pos2], -1, sx, sy, false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10552
5/6
✓ Branch 0 taken 6604 times.
✓ Branch 1 taken 19762 times.
✓ Branch 2 taken 6604 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 400 times.
✓ Branch 5 taken 5681 times.
32447 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10553
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 6572 times.
6604 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10554
3/4
✓ Branch 0 taken 6572 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6081 times.
✓ Branch 3 taken 6049 times.
6604 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10555 {
10556 5681 x=sx;
10557 5681 y=sy;
10558
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 5341 times.
5681 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10559 5681 hxofs=1000; // avoid hit detection
10560 5681 stunclk=0;
10561 5681 placed=true;
10562 5681 }
10563
10564 38464 pos2+=19;
10565
10566
2/2
✓ Branch 0 taken 33901 times.
✓ Branch 1 taken 4563 times.
38464 if(pos2>=176)
10567 4563 pos2-=160;
10568
10569 38464 ++t;
10570 }
10571
10572
3/4
✓ Branch 0 taken 5681 times.
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5681 times.
5746 if(!placed || whistleclk>=88) // can't place him, he's gone
10573 65 return true;
10574
10575 }
10576 5681 break;
10577
10578 case 35:
10579
2/2
✓ Branch 0 taken 3871 times.
✓ Branch 1 taken 1361 times.
5232 if(!get_qr(qr_NEWENEMYTILES))
10580 {
10581 1361 dir=(Hero.y+8<y)?up:down;
10582 1361 }
10583
10584 5232 hxofs=0;
10585 5232 break;
10586
10587 case 35+19:
10588 4993 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10589 4993 sfx(wpnsfx(wpn),pan(int32_t(x)));
10590 4993 break;
10591
10592 case 35+66:
10593 4190 hxofs=1000;
10594 4190 break;
10595
10596 case 198:
10597 2977 clk=-1;
10598 2977 break;
10599 }
10600
10601 853447 return enemy::animate(index);
10602 856401 }
10603
10604 867086 void eZora::draw(BITMAP *dest)
10605 {
10606
2/2
✓ Branch 0 taken 20009 times.
✓ Branch 1 taken 847077 times.
867086 if (isSubmerged())
10607 20009 return;
10608
10609 847077 update_enemy_frame();
10610 847077 enemy::draw(dest);
10611 867086 }
10612
10613 867318 bool eZora::isSubmerged() const
10614 {
10615 867318 return clk < 3;
10616 }
10617
10618
3/6
✓ Branch 0 taken 50201 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50201 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50201 times.
✗ Branch 5 not taken.
100402 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10619 50201 {
10620 50201 multishot= timer = fired = dashing = 0;
10621 50201 hashero = false;
10622 50201 dummy_bool[0]=false;
10623
4/8
✓ Branch 0 taken 50201 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50201 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50201 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50201 times.
✗ Branch 7 not taken.
50201 shield= (flags&(guy_shield_left | guy_shield_right | guy_shield_back |guy_shield_front)) != 0;
10624
5/6
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 49199 times.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 519 times.
✓ Branch 5 taken 483 times.
50201 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10625 {
10626
2/4
✓ Branch 0 taken 519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 519 times.
✗ Branch 3 not taken.
519 step=zslongToFix(dmisc10*100);
10627
10628
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 501 times.
519 if(anim==aARMOS4) o_tile+=20;
10629 519 }
10630
10631
3/4
✓ Branch 0 taken 50201 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✓ Branch 3 taken 49199 times.
50201 if(flags & guy_fade_flicker)
10632 {
10633 1002 clk=0;
10634 1002 superman = 1;
10635 1002 fading=fade_flicker;
10636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
1002 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10637 1002 dir=down;
10638
10639
4/6
✓ Branch 0 taken 1002 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 561 times.
1002 if(!canmove(down,(zfix)8,spw_none,false))
10640
3/6
✓ Branch 0 taken 441 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 441 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 441 times.
✗ Branch 5 not taken.
441 clk3=int32_t(13.0/step);
10641 1002 }
10642
3/4
✓ Branch 0 taken 49199 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49066 times.
✓ Branch 3 taken 133 times.
49199 else if(flags & guy_fade_instant)
10643 {
10644 133 clk=0;
10645 133 }
10646
10647
1/2
✓ Branch 0 taken 50201 times.
✗ Branch 1 not taken.
50201 shadowdistance = 0;
10648 50201 clk4 = clk5 = 0;
10649 //nets+2380;
10650
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 50199 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
50201 if (SIZEflags != 0) init_size_flags();;
10651 50201 }
10652
10653 15785889 bool eStalfos::animate(int32_t index)
10654 {
10655
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 15785633 times.
15785889 if(switch_hooked) return enemy::animate(index);
10656
3/4
✓ Branch 0 taken 15785207 times.
✓ Branch 1 taken 426 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15785207 times.
15785633 if(fallclk||drownclk)
10657 {
10658 426 return enemy::animate(index);
10659 }
10660
2/2
✓ Branch 0 taken 352696 times.
✓ Branch 1 taken 15432511 times.
15785207 if(dying)
10661 {
10662
2/2
✓ Branch 0 taken 352649 times.
✓ Branch 1 taken 47 times.
352696 if(hashero)
10663 {
10664 47 Hero.setEaten(0);
10665 47 hashero=false;
10666 47 }
10667
10668
10/14
✓ Branch 0 taken 35960 times.
✓ Branch 1 taken 316736 times.
✓ Branch 2 taken 3685 times.
✓ Branch 3 taken 32275 times.
✓ Branch 4 taken 187 times.
✓ Branch 5 taken 3498 times.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 187 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 187 times.
352696 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10669 {
10670 187 hp=-1000;
10671
5/10
✓ Branch 0 taken 187 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 187 times.
✗ Branch 9 not taken.
187 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10672 187 Ewpns.add(ew);
10673 187 ew->fakez = fakez;
10674
10675
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
187 if(wpn==ewSBomb || wpn==ewBomb)
10676 {
10677 187 ew->step=0;
10678 187 ew->id=wpn;
10679 187 ew->misc=50;
10680 187 ew->clk=48;
10681 187 }
10682
10683 187 fired=true;
10684 187 }
10685
6/6
✓ Branch 0 taken 156258 times.
✓ Branch 1 taken 196251 times.
✓ Branch 2 taken 130206 times.
✓ Branch 3 taken 26052 times.
✓ Branch 4 taken 130188 times.
✓ Branch 5 taken 18 times.
352509 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10686 {
10687
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10688 {
10689 1 int32_t wpn2 = wpn+dmisc3;
10690
10691
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10692 {
10693 wpn2=wpn;
10694 }
10695
10696 1 dummy_bool[0]=true;
10697 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10698 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10699 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10700 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10701 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10702 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10703 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10704 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10705 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10706 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10707 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10708 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10709 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10710 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10711 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10712 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
10713 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10714 1 }
10715 18 }
10716
10717 352696 KillWeapon();
10718 352696 return Dead(index);
10719 }
10720 //vire split
10721 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10722 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10723
13/14
✓ Branch 0 taken 21125 times.
✓ Branch 1 taken 15411386 times.
✓ Branch 2 taken 21125 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 20774 times.
✓ Branch 6 taken 1192696 times.
✓ Branch 7 taken 14239464 times.
✓ Branch 8 taken 1191149 times.
✓ Branch 9 taken 1547 times.
✓ Branch 10 taken 6686 times.
✓ Branch 11 taken 1184463 times.
✓ Branch 12 taken 1326 times.
✓ Branch 13 taken 5360 times.
15432511 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10724 {
10725 1677 stop_bgsfx(index);
10726 1677 int32_t kids = guys.Count();
10727 1677 int32_t id2=dmisc3;
10728
2/2
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 1677 times.
4984 for(int32_t i=0; i < dmisc4; i++)
10729 {
10730
4/6
✓ Branch 0 taken 1272 times.
✓ Branch 1 taken 2035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2035 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3307 times.
3307 if(addenemy(screen_spawned,x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10731 3307 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10732 3307 }
10733
10734
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1676 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1677 if (itemguy && guys.Count()) // Hand down the carried item
10735 {
10736 1 int guycarryingitem = guys.Count()-1;
10737 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10738 1 itemguy = false;
10739 1 }
10740
10741
2/2
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 17 times.
1677 if(hashero)
10742 {
10743 17 Hero.setEaten(0);
10744 17 hashero=false;
10745 17 }
10746
10747
4/4
✓ Branch 0 taken 1649 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 1326 times.
✓ Branch 3 taken 323 times.
1677 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10748 323 sfx(deadsfx,pan(int32_t(x)));
10749
10750 1677 return true;
10751 }
10752
10753
2/2
✓ Branch 0 taken 71162 times.
✓ Branch 1 taken 15359672 times.
15430834 if(fading)
10754 {
10755
2/2
✓ Branch 0 taken 1228 times.
✓ Branch 1 taken 69934 times.
71162 if(++clk4 > 60)
10756 {
10757 1228 clk4=0;
10758 1228 superman=0;
10759 1228 fading=0;
10760
10761
4/6
✓ Branch 0 taken 967 times.
✓ Branch 1 taken 261 times.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 967 times.
1228 if(flags&guy_armos && z==0 && fakez == 0)
10762 {
10763 //if a custom size (not 16px by 16px)
10764
10765 //if a custom size (not 16px by 16px)
10766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 967 times.
967 if (ffcactivated)
10767 removearmosffc(*ffcactivated);
10768 else
10769 {
10770
4/8
✓ Branch 0 taken 967 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 967 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 967 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 967 times.
967 if (txsz > 1 || tysz > 1 || (SIZEflags&OVERRIDE_HIT_WIDTH) || (SIZEflags&OVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
10771 {
10772 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
10773 for(int32_t dx = 0; dx < tysz; dx ++)
10774 {
10775 for(int32_t dy = 0; dy < tysz; dy++)
10776 {
10777 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
10778 did_armos = false;
10779 }
10780 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
10781 did_armos = false;
10782 }
10783 for(int32_t dy = 0; dy < tysz; dy ++)
10784 {
10785 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
10786 did_armos = false;
10787 }
10788 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
10789 }
10790 967 else removearmos(x,y);
10791 }
10792
10793 967 }
10794
10795 1228 clk2=0;
10796
10797 1228 newdir();
10798 1228 }
10799 69934 else return enemy::animate(index);
10800 1228 }
10801
6/8
✓ Branch 0 taken 148409 times.
✓ Branch 1 taken 15211263 times.
✓ Branch 2 taken 148409 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148409 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 138854 times.
✓ Branch 7 taken 9555 times.
15359672 else if(flags&guy_armos && z==0 && fakez == 0 && clk==0)
10802 9555 removearmos(x,y,ffcactivated);
10803
10804
10805
2/2
✓ Branch 0 taken 6958 times.
✓ Branch 1 taken 15353942 times.
15360900 if(hashero)
10806 {
10807 6958 Hero.setX(x);
10808 6958 Hero.setY(y);
10809 6958 ++clk2;
10810
10811
4/4
✓ Branch 0 taken 5445 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 6061 times.
✓ Branch 3 taken 897 times.
6958 if(clk2==(dmisc8==0 ? 95 : dmisc8))
10812 {
10813
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 877 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
897 switch(dmisc7)
10814 {
10815 case e7tEATITEMS:
10816 {
10817
2/2
✓ Branch 0 taken 5120 times.
✓ Branch 1 taken 20 times.
5140 for(int32_t i=0; i<MAXITEMS; i++)
10818 {
10819
2/2
✓ Branch 0 taken 5100 times.
✓ Branch 1 taken 20 times.
5120 if(itemsbuf[i].flags&item_edible)
10820 20 game->set_item(i, false);
10821 5120 }
10822
10823 20 break;
10824 }
10825
10826 case e7tEATMAGIC:
10827 game->change_dmagic(-1*game->get_magicdrainrate());
10828 break;
10829
10830 case e7tEATRUPEES:
10831 game->change_drupy(-1);
10832 break;
10833 }
10834
10835 897 clk2=0;
10836 897 }
10837
10838
2/2
✓ Branch 0 taken 524 times.
✓ Branch 1 taken 6434 times.
6958 if((clk&0x18)==8) // stop its animation on the middle frame
10839 6434 --clk;
10840 6958 }
10841
4/4
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14305069 times.
✓ Branch 2 taken 616037 times.
✓ Branch 3 taken 432836 times.
15353942 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
10842 {
10843 // Movement engine
10844
6/6
✓ Branch 0 taken 837801 times.
✓ Branch 1 taken 14083305 times.
✓ Branch 2 taken 3294 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 14079844 times.
✓ Branch 5 taken 59 times.
14921106 if(clk>=0) switch(id>>12)
10845 {
10846 case 0: // Normal movement
10847
10848 /*
10849 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
10850 {
10851 // Overloading clk4 (Tribble clock) here...
10852 step=17/100.0;
10853 if(clk4<32) misc=1;
10854 else if(clk4<48) misc=2;
10855 else if(clk4<300) { misc=3; step = dstep/100.0; }
10856 else if(clk4<316) misc=2;
10857 else if(clk4<412) misc=1;
10858 else if(clk4<540) { misc=0; step=0; }
10859 else clk4=0;
10860 if(clk4==48) clk=0;
10861 hxofs=(misc>=2)?0:1000;
10862 if (dmisc9==e9tLEEVER)
10863 variable_walk(rate, homing, 0);
10864 else
10865 variable_walk_8(rate, homing, 4, 0);
10866 break;
10867 }
10868 */
10869
4/4
✓ Branch 0 taken 13700810 times.
✓ Branch 1 taken 379034 times.
✓ Branch 2 taken 417076 times.
✓ Branch 3 taken 13283734 times.
14079844 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
10870 {
10871 796110 vire_hop();
10872 796110 break;
10873 }
10874
2/2
✓ Branch 0 taken 980832 times.
✓ Branch 1 taken 12302902 times.
13283734 else if(dmisc9==e9tROPE) //Rope charge
10875 {
10876
9/10
✓ Branch 0 taken 963410 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 137441 times.
✓ Branch 3 taken 825969 times.
✓ Branch 4 taken 125356 times.
✓ Branch 5 taken 12085 times.
✓ Branch 6 taken 124531 times.
✓ Branch 7 taken 825 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 124531 times.
980832 if(!fired && dashing && !stunclk && !watch && !frozenclock)
10877 {
10878
5/6
✓ Branch 0 taken 9076 times.
✓ Branch 1 taken 115455 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 9029 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
124531 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
10879 {
10880
10881
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 33 times.
47 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
10882 {
10883 14 hp=-1000;
10884
10885
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10886 {
10887
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
10888 14 Ewpns.add(ew);
10889 14 ew->fakez = fakez;
10890
10891
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
10892 {
10893 14 ew->step=0;
10894 14 ew->id=wpn+dmisc3;
10895 14 ew->misc=50;
10896 14 ew->clk=48;
10897 14 }
10898
10899 14 fired=true;
10900 14 }
10901 else
10902 {
10903 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
10904 Ewpns.add(ew);
10905 ew->fakez = fakez;
10906
10907 if(wpn==ewSBomb || wpn==ewBomb)
10908 {
10909 ew->step=0;
10910 ew->id=wpn;
10911 ew->misc=50;
10912 ew->clk=48;
10913 }
10914
10915 fired=true;
10916 }
10917 14 }
10918
10919 else
10920 {
10921 33 hp=-1000;
10922
10923 int32_t wpn2;
10924
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
10925 33 wpn2=wpn;
10926 else
10927 wpn2=wpn;
10928
10929
5/10
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 33 times.
✗ Branch 9 not taken.
33 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
10930 33 Ewpns.add(ew);
10931 33 ew->fakez = fakez;
10932
10933
3/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
33 if(wpn2==ewSBomb || wpn2==ewBomb)
10934 {
10935 33 ew->step=0;
10936 33 ew->id=wpn2;
10937 33 ew->misc=50;
10938 33 ew->clk=48;
10939 33 }
10940
10941 33 fired=true;
10942 }
10943 47 }
10944 124531 }
10945
10946 980832 charge_attack();
10947 980832 break;
10948 }
10949 /*
10950 * Boomerang-throwers have a halt count of 1
10951 * Zols have a halt count of (zc_oldrand()&7)<<4
10952 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
10953 * Everything else has 48
10954 */
10955 else
10956 {
10957
2/2
✓ Branch 0 taken 568419 times.
✓ Branch 1 taken 11734483 times.
12302902 if(wpn==ewBrang) // Goriya
10958 {
10959 568419 halting_walk(rate,homing,0,hrate, 1);
10960 568419 }
10961
4/4
✓ Branch 0 taken 11585107 times.
✓ Branch 1 taken 149376 times.
✓ Branch 2 taken 4550102 times.
✓ Branch 3 taken 7035005 times.
11734483 else if(dmisc9==e9tNORMAL && wpn==0)
10962 {
10963
2/2
✓ Branch 0 taken 717973 times.
✓ Branch 1 taken 6317032 times.
7035005 if(dmisc2==e2tSPLITHIT) // Zol
10964 {
10965 717973 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
10966 717973 }
10967
4/4
✓ Branch 0 taken 1754155 times.
✓ Branch 1 taken 4562877 times.
✓ Branch 2 taken 1538264 times.
✓ Branch 3 taken 215891 times.
6317032 else if(frate<=8 && starting_hp==1) // Gel
10968 {
10969 215891 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
10970 215891 }
10971 else // Other
10972 {
10973 6101141 halting_walk(rate,homing,0,hrate, 48);
10974 }
10975 7035005 }
10976 else // Other
10977 {
10978 4699478 halting_walk(rate,homing,0,hrate, 48);
10979 }
10980 }
10981
10982 //if not in midair, and Hero's swinging sword is nearby, jump.
10983 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
10984 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
10985 {
10986 facehero(false);
10987 sclk=16+((dir^1)<<8);
10988 fall=-FEATHERJUMP;
10989 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
10990 }*/
10991 12302902 break;
10992
10993 // Following cases are for just after creation-by-splitting.
10994 case 1:
10995
2/2
✓ Branch 0 taken 2473 times.
✓ Branch 1 taken 821 times.
3294 if(misc==1)
10996 {
10997 821 dir=up;
10998 821 step=8;
10999 821 }
11000
11001
2/2
✓ Branch 0 taken 790 times.
✓ Branch 1 taken 2504 times.
3294 if(misc<=2)
11002 {
11003 2504 move(step);
11004
11005
2/2
✓ Branch 0 taken 1992 times.
✓ Branch 1 taken 512 times.
2504 if(!canmove(dir,(zfix)0,0,false))
11006 512 dir=down;
11007 2504 }
11008
11009
2/2
✓ Branch 0 taken 2504 times.
✓ Branch 1 taken 790 times.
3294 if(misc==3)
11010 {
11011
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 503 times.
790 if(canmove(right,(zfix)16,0,false))
11012 503 x+=16;
11013 790 }
11014
11015 3294 ++misc;
11016 3294 break;
11017
11018 case 2:
11019
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 15 times.
59 if(misc==1)
11020 {
11021 15 dir=down;
11022 15 step=8;
11023 15 }
11024
11025
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45 times.
59 if(misc<=2)
11026 {
11027 45 move(step);
11028 /*
11029 if(!canmove(dir,(zfix)0,0,false))
11030 dir=up;
11031 */
11032 45 }
11033
11034
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 14 times.
59 if(misc==3)
11035 {
11036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(canmove(left,(zfix)16,0,false))
11037 14 x-=16;
11038 14 }
11039
11040 59 ++misc;
11041 59 break;
11042
11043 default:
11044
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 28 times.
108 if(misc==1)
11045 {
11046 28 dir=(zc_oldrand()%4);
11047 28 step=8;
11048 28 }
11049
11050
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 83 times.
108 if(misc<=2)
11051 {
11052 83 move(step);
11053
11054
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
83 if(!canmove(dir,(zfix)0,0,false))
11055 2 dir=dir^1;
11056 83 }
11057
11058
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 25 times.
108 if(misc==3)
11059 {
11060
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
25 if(dir >= left && canmove(dir,(zfix)16,0,false))
11061 8 x+=(dir==left ? -16 : 16);
11062 25 }
11063
11064 108 ++misc;
11065 108 break;
11066 14083305 }
11067
11068
4/4
✓ Branch 0 taken 25272 times.
✓ Branch 1 taken 14895834 times.
✓ Branch 2 taken 24443 times.
✓ Branch 3 taken 829 times.
14921106 if(id>>12 && misc>=4) //recently spawned by a split enemy
11069 {
11070 829 id&=0xFFF;
11071 829 step = zslongToFix(dstep*100);
11072
11073
1/2
✓ Branch 0 taken 829 times.
✗ Branch 1 not taken.
829 if(x<32) x=32;
11074
11075
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 21 times.
829 if(x>world_w-48) x=world_w-48;
11076
11077
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 24 times.
829 if(y<32) y=32;
11078
11079
2/2
✓ Branch 0 taken 822 times.
✓ Branch 1 taken 7 times.
829 if(y>world_h-48) y=world_h-48;
11080
11081 829 misc=3;
11082 829 }
11083 14921106 }
11084 else
11085 {
11086 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11087
1/2
✓ Branch 0 taken 432836 times.
✗ Branch 1 not taken.
432836 if(clk2>2) clk2--;
11088 }
11089
11090 // Fire Zol
11091
8/8
✓ Branch 0 taken 6101768 times.
✓ Branch 1 taken 9259132 times.
✓ Branch 2 taken 139281 times.
✓ Branch 3 taken 5962487 times.
✓ Branch 4 taken 1131 times.
✓ Branch 5 taken 138150 times.
✓ Branch 6 taken 1102 times.
✓ Branch 7 taken 29 times.
15360900 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11092 {
11093 1102 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11094 1102 sfx(wpnsfx(wpn),pan(int32_t(x)));
11095
11096 1102 int32_t i=Ewpns.Count()-1;
11097 1102 weapon *ew = (weapon*)(Ewpns.spr(i));
11098
11099
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1102 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11100 {
11101 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11102 if ( ew->do_animation ) ew->tile+=ew->aframe;
11103 }
11104 1102 }
11105 // Goriya
11106
14/16
✓ Branch 0 taken 1048873 times.
✓ Branch 1 taken 14310925 times.
✓ Branch 2 taken 468534 times.
✓ Branch 3 taken 580339 times.
✓ Branch 4 taken 456235 times.
✓ Branch 5 taken 12299 times.
✓ Branch 6 taken 423258 times.
✓ Branch 7 taken 32977 times.
✓ Branch 8 taken 423258 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 420517 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 420517 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 414155 times.
✓ Branch 15 taken 6362 times.
15359798 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11107 {
11108 6362 misc=index+100;
11109
7/14
✓ Branch 0 taken 6362 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6362 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6362 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6362 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6362 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6362 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6362 times.
✗ Branch 13 not taken.
6362 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11110 6362 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11111
11112
2/2
✓ Branch 0 taken 6105 times.
✓ Branch 1 taken 257 times.
6362 if(dmisc1==2)
11113 {
11114 257 int32_t ndir=dir;
11115
11116
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 251 times.
257 if(Hero.x-x==0)
11117 {
11118 6 ndir=(Hero.y+8<y)?up:down;
11119 6 }
11120 else //turn to face Hero
11121 {
11122 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11123 251 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11124
11125
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 193 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 13 times.
251 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11126 {
11127 13 ndir=down;
11128 13 }
11129
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 68 times.
238 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11130 {
11131 68 ndir=right;
11132 68 }
11133
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 48 times.
170 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11134 {
11135 48 ndir=up;
11136 48 }
11137 else
11138 {
11139 122 ndir=left;
11140 }
11141 }
11142
11143 257 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11144
11145
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 223 times.
257 if(canmove(ndir,false))
11146 {
11147 223 dir=ndir;
11148 223 }
11149 257 }
11150 6362 }
11151
15/16
✓ Branch 0 taken 15294566 times.
✓ Branch 1 taken 58870 times.
✓ Branch 2 taken 221182 times.
✓ Branch 3 taken 15132254 times.
✓ Branch 4 taken 195067 times.
✓ Branch 5 taken 26115 times.
✓ Branch 6 taken 170175 times.
✓ Branch 7 taken 24892 times.
✓ Branch 8 taken 168791 times.
✓ Branch 9 taken 1384 times.
✓ Branch 10 taken 153691 times.
✓ Branch 11 taken 15100 times.
✓ Branch 12 taken 153691 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 152747 times.
15353436 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11152
3/3
✓ Branch 0 taken 26109 times.
✓ Branch 1 taken 125732 times.
✓ Branch 2 taken 906 times.
152747 switch(dmisc1)
11153 {
11154 case e1tCONSTANT: //Deathnut
11155 {
11156 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11157
2/2
✓ Branch 0 taken 123149 times.
✓ Branch 1 taken 2583 times.
125732 if(clk5>64)
11158 {
11159 2583 clk5=0;
11160 2583 fired=false;
11161 2583 }
11162
11163 125732 clk5+=(zc_oldrand()&3);
11164
11165
4/4
✓ Branch 0 taken 76714 times.
✓ Branch 1 taken 49018 times.
✓ Branch 2 taken 25645 times.
✓ Branch 3 taken 51069 times.
125732 if((clk5>24)&&(clk5<52))
11166 {
11167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51069 times.
51069 if ( do_animation )tile+=20; //firing
11168
11169
4/4
✓ Branch 0 taken 27958 times.
✓ Branch 1 taken 23111 times.
✓ Branch 2 taken 25131 times.
✓ Branch 3 taken 2827 times.
51069 if(!fired&&(clk5>=38))
11170 {
11171
5/10
✓ Branch 0 taken 2827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2827 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2827 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2827 times.
✗ Branch 9 not taken.
2827 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11172 2827 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11173 2827 sfx(wpnsfx(wpn),pan(int32_t(x)));
11174 2827 fired=true;
11175 2827 }
11176 51069 }
11177
11178 125732 break;
11179 }
11180
11181 case e1tFIREOCTO: //Fire Octo
11182 906 timer=zc_oldrand()%50+50;
11183 906 break;
11184
11185 default:
11186 26109 FireWeapon();
11187 26109 break;
11188 152747 }
11189
11190 /* Fire again if:
11191 * - clk2 about to run out
11192 * - not already double-firing (dmisc1 is 1)
11193 * - not carrying Hero
11194 * - one in 0xF chance
11195 */
11196
8/10
✓ Branch 0 taken 524925 times.
✓ Branch 1 taken 14835975 times.
✓ Branch 2 taken 4002 times.
✓ Branch 3 taken 520923 times.
✓ Branch 4 taken 4002 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4002 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3751 times.
✓ Branch 9 taken 251 times.
15360900 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11197 {
11198 #if 1
11199 251 newdir(rate, homing, grumble);
11200 #else
11201 dir^=2;
11202 #endif
11203 251 clk2=28;
11204 251 ++multishot;
11205 251 }
11206
11207
2/2
✓ Branch 0 taken 3491786 times.
✓ Branch 1 taken 11869114 times.
15360900 if(clk2==0)
11208 {
11209 11869114 multishot = 0;
11210 11869114 }
11211
11212
2/2
✓ Branch 0 taken 15296590 times.
✓ Branch 1 taken 64310 times.
15360900 if(timer) //Fire Octo
11213 {
11214 64310 clk2=15; //this keeps the octo in place until he's done firing
11215
11216
2/2
✓ Branch 0 taken 48558 times.
✓ Branch 1 taken 15752 times.
64310 if(!(timer%4))
11217 {
11218 15752 FireBreath(false);
11219 15752 }
11220
11221 64310 --timer;
11222 64310 }
11223
11224
2/2
✓ Branch 0 taken 15111507 times.
✓ Branch 1 taken 249393 times.
15360900 if(dmisc2==e2tTRIBBLE)
11225 249393 ++clk4;
11226
11227
7/10
✓ Branch 0 taken 4480 times.
✓ Branch 1 taken 15356420 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 15360207 times.
✓ Branch 4 taken 693 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 693 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 693 times.
15360900 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11228 {
11229 693 int32_t kids = guys.Count();
11230 693 int32_t id2=dmisc3;
11231
11232
2/2
✓ Branch 0 taken 693 times.
✓ Branch 1 taken 693 times.
1386 for(int32_t i=0; i<dmisc4; i++)
11233 {
11234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 693 times.
693 if(addenemy(screen_spawned,x,y,id2,-24))
11235 {
11236
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(itemguy) // Hand down the carried item
11237 {
11238 int guycarryingitem = guys.Count()-1;
11239 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11240 itemguy = false;
11241 }
11242
11243 693 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11244 693 }
11245 693 }
11246
11247
1/2
✓ Branch 0 taken 693 times.
✗ Branch 1 not taken.
693 if(hashero)
11248 {
11249 Hero.setEaten(0);
11250 hashero=false;
11251 }
11252
11253 693 stop_bgsfx(index);
11254 693 return true;
11255 }
11256
11257 15360207 return enemy::animate(index);
11258 15785889 }
11259
11260 16207922 void eStalfos::draw(BITMAP *dest)
11261 {
11262 16207922 update_enemy_frame();
11263
11264
7/8
✓ Branch 0 taken 16207496 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 16207496 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 86951 times.
✓ Branch 5 taken 16120545 times.
✓ Branch 6 taken 75836 times.
✓ Branch 7 taken 11115 times.
16207922 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11265 {
11266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11115 times.
11115 if ( do_animation )tile+=20;
11267 11115 }
11268
11269 16207922 enemy::draw(dest);
11270 16207922 }
11271
11272 7537604 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11273 {
11274 7537604 int32_t tempy=yofs;
11275
11276
4/4
✓ Branch 0 taken 7322186 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7225985 times.
✓ Branch 3 taken 311619 times.
7537604 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11277 {
11278 311619 flip = 0;
11279 311619 int32_t fdiv = frate/4;
11280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 311619 times.
311619 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11281
11282
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11283 311619 efrate:((clk>=(frate>>1))?1:0);
11284 311619 shadowtile = wpnsbuf[spr_shadow].tile;
11285
11286
1/2
✓ Branch 0 taken 311619 times.
✗ Branch 1 not taken.
311619 if(get_qr(qr_NEWENEMYTILES))
11287 {
11288 311619 shadowtile+=f2;
11289 311619 }
11290 else
11291 {
11292 shadowtile+=f2?1:0;
11293 }
11294
11295 311619 yofs+=shadowdistance;
11296 311619 yofs+=8;
11297 311619 }
11298
4/4
✓ Branch 0 taken 7322186 times.
✓ Branch 1 taken 215418 times.
✓ Branch 2 taken 7534569 times.
✓ Branch 3 taken 3035 times.
7537604 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11299 {
11300 3035 flip = 0;
11301 3035 int32_t fdiv = frate/4;
11302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3035 times.
3035 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11303
11304
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11305 3035 efrate:((clk>=(frate>>1))?1:0);
11306 3035 shadowtile = wpnsbuf[spr_shadow].tile;
11307
11308
1/2
✓ Branch 0 taken 3035 times.
✗ Branch 1 not taken.
3035 if(get_qr(qr_NEWENEMYTILES))
11309 {
11310 3035 shadowtile+=f2;
11311 3035 }
11312 else
11313 {
11314 shadowtile+=f2?1:0;
11315 }
11316 3035 }
11317
2/2
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 7532108 times.
7537604 if(!shadow_overpit(this))
11318 7532108 enemy::drawshadow(dest, translucent);
11319 7537604 yofs=tempy;
11320 7537604 }
11321
11322 157765 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11323 {
11324 157765 int32_t wpnId = w->id;
11325 157765 int32_t wpnDir = w->dir;
11326
11327
4/4
✓ Branch 0 taken 1418 times.
✓ Branch 1 taken 156347 times.
✓ Branch 2 taken 609 times.
✓ Branch 3 taken 809 times.
157765 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11328
6/8
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 385 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 265 times.
✓ Branch 5 taken 120 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 120 times.
609 && ((flags&guy_shield_front && wpnDir==(dir^down)) || (flags&guy_shield_back && wpnDir==(dir^up))
11329
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
120 || (flags&guy_shield_left && wpnDir==(dir^left)) || (flags&guy_shield_right && wpnDir==(dir^right))))
11330 {
11331 265 shield = false;
11332 265 flags &= ~(guy_shield_left|guy_shield_right|guy_shield_back|guy_shield_front);
11333
11334
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 243 times.
265 if(get_qr(qr_BRKNSHLDTILES))
11335 243 o_tile=s_tile;
11336 265 }
11337
11338 157765 int32_t ret = enemy::takehit(w,realweap);
11339
11340
4/4
✓ Branch 0 taken 22299 times.
✓ Branch 1 taken 135466 times.
✓ Branch 2 taken 20548 times.
✓ Branch 3 taken 1751 times.
157765 if(sclk && dmisc2==e2tSPLITHIT)
11341 1751 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11342
11343 157765 return ret;
11344 }
11345
11346 980832 void eStalfos::charge_attack()
11347 {
11348
2/2
✓ Branch 0 taken 6656 times.
✓ Branch 1 taken 974176 times.
980832 if(slide())
11349 6656 return;
11350
11351
10/12
✓ Branch 0 taken 974176 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 971772 times.
✓ Branch 3 taken 2404 times.
✓ Branch 4 taken 942259 times.
✓ Branch 5 taken 29513 times.
✓ Branch 6 taken 920706 times.
✓ Branch 7 taken 21553 times.
✓ Branch 8 taken 915083 times.
✓ Branch 9 taken 5623 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 915083 times.
974176 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11352 59093 return;
11353
11354
2/2
✓ Branch 0 taken 37327 times.
✓ Branch 1 taken 877756 times.
915083 if(clk3<=0)
11355 {
11356 37327 fix_coords(true);
11357
11358
2/2
✓ Branch 0 taken 9937 times.
✓ Branch 1 taken 27390 times.
37327 if(!dashing)
11359 {
11360 27390 int32_t ldir = lined_up(7,false);
11361
11362
4/4
✓ Branch 0 taken 3088 times.
✓ Branch 1 taken 24302 times.
✓ Branch 2 taken 454 times.
✓ Branch 3 taken 2634 times.
27390 if(ldir!=-1 && canmove(ldir,false))
11363 {
11364 2634 dir=ldir;
11365 2634 dashing=true;
11366
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2634 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2634 if (dmisc10<=0 || replay_version_check(0,33) || get_qr(qr_ROPE_ENEMIES_SPEED_NOT_CONFIGURABLE))
11367 2634 step=zslongToFix(dstep*100)+1;
11368 else
11369 step=zslongToFix(dmisc10*100);
11370 2634 }
11371 24756 else newdir(4,0,0);
11372 27390 }
11373
11374
2/2
✓ Branch 0 taken 35886 times.
✓ Branch 1 taken 1441 times.
37327 if(!canmove(dir,false))
11375 {
11376 1441 step=zslongToFix(dstep*100);
11377 1441 newdir();
11378 1441 dashing=false;
11379 1441 }
11380
11381 37327 zfix div = step;
11382
11383
1/2
✓ Branch 0 taken 37327 times.
✗ Branch 1 not taken.
37327 if(div == 0)
11384 div = 1;
11385
11386 37327 clk3=(int32_t)(16.0/div);
11387 37327 return;
11388 }
11389
11390 877756 move(step);
11391 877756 --clk3;
11392 980832 }
11393
11394 796110 void eStalfos::vire_hop()
11395 {
11396
2/2
✓ Branch 0 taken 379034 times.
✓ Branch 1 taken 417076 times.
796110 if(dmisc9!=e9tPOLSVOICE)
11397 {
11398
2/2
✓ Branch 0 taken 372449 times.
✓ Branch 1 taken 6585 times.
379034 if(sclk!=0)
11399 {
11400
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 3843 times.
6585 if (dmisc2==e2tSPLITHIT) return;
11401 3843 }
11402 376292 }
11403 417076 else sclk=0;
11404
11405
8/12
✓ Branch 0 taken 793368 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 793368 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 777885 times.
✓ Branch 5 taken 15483 times.
✓ Branch 6 taken 761476 times.
✓ Branch 7 taken 16409 times.
✓ Branch 8 taken 761476 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 761476 times.
793368 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11406 31892 return;
11407
11408 761476 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11409 int32_t jump_height;
11410
11411
1/2
✓ Branch 0 taken 761476 times.
✗ Branch 1 not taken.
761476 if ((dmisc10 <= 0))
11412 761476 jump_height = (dmisc9 == e9tPOLSVOICE) ? 27 : 16;
11413 else jump_height = dmisc10;
11414
11415 761476 y=floor_y;
11416
11417
2/2
✓ Branch 0 taken 735218 times.
✓ Branch 1 taken 26258 times.
761476 if(clk3<=0)
11418 {
11419 26258 fix_coords();
11420
11421 //z=0;
11422 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11423 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11424
9/10
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 602 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 4226 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
26258 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & move_obeys_grav)))) //Vires in old quests
11425 22032 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11426
11427
2/2
✓ Branch 0 taken 4922 times.
✓ Branch 1 taken 21336 times.
26258 if(clk2<=0)
11428 {
11429 //z=0;
11430
6/6
✓ Branch 0 taken 19015 times.
✓ Branch 1 taken 2321 times.
✓ Branch 2 taken 18569 times.
✓ Branch 3 taken 446 times.
✓ Branch 4 taken 14491 times.
✓ Branch 5 taken 4078 times.
21336 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11431 {
11432
11433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17258 times.
17258 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11434 17258 }
11435 21336 }
11436
11437
4/4
✓ Branch 0 taken 12099 times.
✓ Branch 1 taken 14159 times.
✓ Branch 2 taken 5069 times.
✓ Branch 3 taken 7030 times.
26258 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11438 {
11439 7030 clk2=int32_t((16.0*jump_width)/step.getFloat());
11440 7030 }
11441
11442 26258 clk3=int32_t(16.0/step.getFloat());
11443 26258 }
11444
11445 761476 --clk3;
11446
11447
3/4
✓ Branch 0 taken 361067 times.
✓ Branch 1 taken 400409 times.
✓ Branch 2 taken 361067 times.
✗ Branch 3 not taken.
761476 if(dmisc9==e9tPOLSVOICE || clk2>0)
11448 761476 move(step);
11449
11450 761476 floor_y=y;
11451 761476 clk2--;
11452
11453 //if we're in the middle of a jump
11454
6/6
✓ Branch 0 taken 624929 times.
✓ Branch 1 taken 136547 times.
✓ Branch 2 taken 257704 times.
✓ Branch 3 taken 367225 times.
✓ Branch 4 taken 110653 times.
✓ Branch 5 taken 147051 times.
761476 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11455 {
11456 477878 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11457
11458
4/4
✓ Branch 0 taken 99298 times.
✓ Branch 1 taken 378580 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 93147 times.
477878 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11459 {
11460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93147 times.
93147 if (moveflags & move_use_fake_z) fakez=h;
11461 93147 else z=h;
11462 93147 }
11463 else
11464 {
11465 384731 y=floor_y-h;
11466 384731 shadowdistance=h;
11467 }
11468 477878 }
11469 else
11470 283598 shadowdistance = 0;
11471 796110 }
11472
11473 137 void eStalfos::eathero()
11474 {
11475
5/8
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 69 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 69 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 69 times.
137 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11476 {
11477 69 hashero=true;
11478 69 y=floor_y;
11479 69 z=0;
11480
11481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(Hero.isSwimming())
11482 {
11483 Hero.setX(x);
11484 Hero.setY(y);
11485 }
11486 else
11487 {
11488 69 x=Hero.getX();
11489 69 y=Hero.getY();
11490 }
11491
11492 69 clk2=0;
11493 69 }
11494 137 }
11495
11496 1469390 bool eStalfos::WeaponOut()
11497 {
11498
2/2
✓ Branch 0 taken 2400579 times.
✓ Branch 1 taken 622399 times.
3022978 for(int32_t i=0; i<Ewpns.Count(); i++)
11499 {
11500
3/4
✓ Branch 0 taken 846991 times.
✓ Branch 1 taken 1553588 times.
✓ Branch 2 taken 846991 times.
✗ Branch 3 not taken.
2400579 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11501 {
11502 846991 return true;
11503 }
11504 1553588 }
11505
11506 622399 return false;
11507 1469390 }
11508
11509 352696 void eStalfos::KillWeapon()
11510 {
11511
2/2
✓ Branch 0 taken 293348 times.
✓ Branch 1 taken 352696 times.
646044 for(int32_t i=0; i<Ewpns.Count(); i++)
11512 {
11513
4/4
✓ Branch 0 taken 245250 times.
✓ Branch 1 taken 48098 times.
✓ Branch 2 taken 244440 times.
✓ Branch 3 taken 810 times.
293348 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11514 {
11515 //only kill this Goriya's boomerang -DD
11516
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 411 times.
810 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11517 {
11518 411 Ewpns.del(i);
11519 411 }
11520 810 }
11521 293348 }
11522 352696 }
11523
11524 void eStalfos::break_shield()
11525 {
11526 if(!shield)
11527 return;
11528
11529 flags&=~(guy_shield_front | guy_shield_back | guy_shield_left | guy_shield_right);
11530 shield=false;
11531
11532 if(get_qr(qr_BRKNSHLDTILES))
11533 o_tile=s_tile;
11534 }
11535
11536 void eStalfos::repair_shield()
11537 {
11538 if (shield)
11539 return;
11540
11541 shield = true;
11542
11543 if (get_qr(qr_BRKNSHLDTILES))
11544 {
11545 if get_qr(qr_NEWENEMYTILES) o_tile = d->e_tile;
11546 else o_tile = d->tile;
11547 }
11548 }
11549
11550 13720 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11551 13720 {
11552
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 dir=(zc_oldrand()&7)+8;
11553
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 step=0;
11554 13720 movestatus=1;
11555
3/4
✓ Branch 0 taken 10596 times.
✓ Branch 1 taken 3124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10596 times.
13720 if (dmisc1 != 1 && dmisc19 > 0)
11556 {
11557 step = dmisc19/100.0;
11558 movestatus = 1;
11559 }
11560
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if (dmisc1 == 2) movestatus=2;
11561 13720 c=0;
11562 13720 clk4=0;
11563 //nets;
11564
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 init_size_flags();
11565 13720 dummy_int[1]=0;
11566 13720 }
11567
11568 3535341 bool eKeese::animate(int32_t index)
11569 {
11570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3535341 times.
3535341 if(switch_hooked) return enemy::animate(index);
11571
2/4
✓ Branch 0 taken 3535341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3535341 times.
3535341 if(fallclk||drownclk) return enemy::animate(index);
11572
2/2
✓ Branch 0 taken 124509 times.
✓ Branch 1 taken 3410832 times.
3535341 if(dying)
11573 124509 return Dead(index);
11574
11575
2/2
✓ Branch 0 taken 3384641 times.
✓ Branch 1 taken 26191 times.
3410832 if(clk==0)
11576 {
11577 26191 removearmos(x,y,ffcactivated);
11578 26191 }
11579
11580
2/2
✓ Branch 0 taken 1025042 times.
✓ Branch 1 taken 2385790 times.
3410832 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11581 {
11582 1025042 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11583 1025042 }
11584 else
11585 {
11586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2385790 times.
2385790 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11587 2385790 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11588 }
11589
11590
2/2
✓ Branch 0 taken 120338 times.
✓ Branch 1 taken 3290494 times.
3410832 if(dmisc2 == e2tKEESETRIB)
11591 {
11592
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120338 times.
✓ Branch 2 taken 120147 times.
✓ Branch 3 taken 191 times.
120338 if(++clk4==(dmisc20>0?dmisc20:256))
11593 {
11594
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 105 times.
191 if(!m_walkflag(x,y,0, dir))
11595 {
11596 105 int32_t kids = guys.Count();
11597 105 bool success = false;
11598 105 int32_t id2=dmisc3;
11599 105 success = 0 != addenemy(screen_spawned,(zfix)x,(zfix)y,id2,-24);
11600
11601
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if(success)
11602 {
11603
1/2
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
105 if(itemguy) // Hand down the carried item
11604 {
11605 int guycarryingitem = guys.Count()-1;
11606 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11607 itemguy = false;
11608 }
11609
11610 105 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11611 105 }
11612
11613 105 stop_bgsfx(index);
11614 105 return true;
11615 }
11616 else
11617 {
11618 86 clk4=0;
11619 }
11620 86 }
11621 120233 }
11622 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11623
3/4
✓ Branch 0 taken 845879 times.
✓ Branch 1 taken 2444615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 845879 times.
3290494 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11624 {
11625
2/2
✓ Branch 0 taken 687068 times.
✓ Branch 1 taken 158811 times.
845879 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11626 {
11627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 687068 times.
687068 if (moveflags & move_use_fake_z)
11628 {
11629 fakez=int32_t(step/zslongToFix(dstep*100));
11630 // Some variance in keese flight heights when away from Hero
11631 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11632
11633 }
11634 else
11635 {
11636 687068 z=int32_t(step/zslongToFix(dstep*100));
11637 // Some variance in keese flight heights when away from Hero
11638
2/2
✓ Branch 0 taken 503635 times.
✓ Branch 1 taken 183433 times.
687068 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11639 }
11640 687068 }
11641 else
11642 {
11643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158811 times.
158811 if (moveflags & move_use_fake_z)
11644 {
11645 fakez=int32_t(step/zslongToFix(dstep*100));
11646 // Some variance in keese flight heights when away from Hero
11647 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11648
11649 }
11650 else
11651 {
11652 158811 z=int32_t(step/zslongToFix(dstep*100));
11653 // Some variance in keese flight heights when away from Hero
11654
2/2
✓ Branch 0 taken 16841 times.
✓ Branch 1 taken 141970 times.
158811 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
11655 }
11656 }
11657 845879 }
11658
11659 3410727 return enemy::animate(index);
11660 3535341 }
11661
11662 2088281 void eKeese::drawshadow(BITMAP *dest, bool translucent)
11663 {
11664 2088281 int32_t tempy=yofs;
11665 2088281 flip = 0;
11666 2088281 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11667
11668
2/2
✓ Branch 0 taken 667695 times.
✓ Branch 1 taken 1420586 times.
2088281 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
11669
2/2
✓ Branch 0 taken 690563 times.
✓ Branch 1 taken 1397718 times.
2088281 if(!get_qr(qr_ENEMIESZAXIS))
11670 {
11671 1397718 yofs+=int32_t(step/zslongToFix(dstep*10));
11672 1397718 }
11673
11674
6/6
✓ Branch 0 taken 2067591 times.
✓ Branch 1 taken 20690 times.
✓ Branch 2 taken 676820 times.
✓ Branch 3 taken 1390771 times.
✓ Branch 4 taken 661452 times.
✓ Branch 5 taken 15368 times.
2088281 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
11675 2052223 enemy::drawshadow(dest, translucent);
11676 2088281 yofs=tempy;
11677 2088281 }
11678
11679 7949863 void eKeese::draw(BITMAP *dest)
11680 {
11681 7949863 update_enemy_frame();
11682 7949863 enemy::draw(dest);
11683 7949863 }
11684
11685 13720 void eKeese::init_size_flags()
11686 {
11687 13720 SIZEflags = d->SIZEflags;
11688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_X_OFFSET)) hxofs = 2;
11689
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
11690
11691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_WIDTH)) hit_width = 12;
11692
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0) hit_width = d->hxsz;
11693
11694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_Y_OFFSET)) hyofs = 4;
11695
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
11696
11697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
13720 if (!(SIZEflags & OVERRIDE_HIT_HEIGHT)) hit_height = 8;
11698
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0) hit_height = d->hysz;
11699
11700
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11701 // al_trace("Enemy txsz:%i\n", txsz);
11702
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13720 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
11703
11704
11705
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13720 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0) hzsz = d->hzsz;
11706
11707
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
11708
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
11709 {
11710 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11711 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
11712 }
11713
11714
1/2
✓ Branch 0 taken 13720 times.
✗ Branch 1 not taken.
13720 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
11715 13720 }
11716
11717 20171 void eWizzrobe::submerge(bool set)
11718 {
11719
2/2
✓ Branch 0 taken 20024 times.
✓ Branch 1 taken 147 times.
20171 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
11720 {
11721 20024 hxofs = set?1000:0;
11722 20024 return;
11723 }
11724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if(submerged == set) return;
11725 147 submerged = set;
11726
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 71 times.
147 if(set)
11727 76 hxofs+=1000;
11728 71 else hxofs -= 1000;
11729 20171 }
11730 5350 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11731 5350 {
11732 5350 hxofs = 0;
11733 5350 submerged = false;
11734
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 switch(dmisc1)
11735 {
11736 case 0:
11737 2992 submerge(true);
11738 2992 fading=fade_invisible;
11739 // Set clk to just before the 'reappear' threshold
11740
9/10
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2991 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 1808 times.
✓ Branch 6 taken 1184 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1807 times.
✓ Branch 9 taken 1 times.
2992 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
11741 2992 break;
11742
11743 default:
11744 2358 dir=(loadside==right)?right:left;
11745 2358 misc=-3;
11746 2358 break;
11747 }
11748
11749 //netst+2880;
11750 5350 charging=false;
11751 5350 firing=false;
11752 5350 fclk=0;
11753
2/2
✓ Branch 0 taken 2358 times.
✓ Branch 1 taken 2992 times.
5350 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
11754
1/4
✓ Branch 0 taken 5350 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5350 if (SIZEflags != 0) init_size_flags();;
11755 5350 }
11756
11757 2081613 bool eWizzrobe::animate(int32_t index)
11758 {
11759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2081613 times.
2081613 if(switch_hooked) return enemy::animate(index);
11760
2/4
✓ Branch 0 taken 2081613 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2081613 times.
2081613 if(fallclk||drownclk) return enemy::animate(index);
11761
2/2
✓ Branch 0 taken 38023 times.
✓ Branch 1 taken 2043590 times.
2081613 if(dying)
11762 {
11763 38023 return Dead(index);
11764 }
11765
11766
2/2
✓ Branch 0 taken 1976944 times.
✓ Branch 1 taken 66646 times.
2043590 if(clk==0)
11767 {
11768 66646 removearmos(x,y,ffcactivated);
11769 66646 }
11770
11771
2/2
✓ Branch 0 taken 1019220 times.
✓ Branch 1 taken 1024370 times.
2043590 if(dmisc1) // Floating
11772 {
11773 1019220 wizzrobe_attack();
11774 1019220 }
11775 else // Teleporting
11776 {
11777
5/6
✓ Branch 0 taken 1017286 times.
✓ Branch 1 taken 7084 times.
✓ Branch 2 taken 11087 times.
✓ Branch 3 taken 1006199 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11087 times.
1024370 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
11778 {
11779 7084 fading=0;
11780 7084 submerge(false);
11781 7084 solid_update(false);
11782 7084 }
11783
8/8
✓ Branch 0 taken 983365 times.
✓ Branch 1 taken 6240 times.
✓ Branch 2 taken 5313 times.
✓ Branch 3 taken 5151 times.
✓ Branch 4 taken 5006 times.
✓ Branch 5 taken 4247 times.
✓ Branch 6 taken 4109 times.
✓ Branch 7 taken 3855 times.
1017286 else switch(clk)
11784 {
11785 case 0:
11786
2/2
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 5123 times.
6240 if(!dmisc2)
11787 {
11788 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
11789 // but should not appear on dungeon walls.
11790
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 4710 times.
5123 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
11791
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 4486 times.
4710 else if (editorflags&ENEMY_FLAG5)
11792 {
11793 //2.10 Windrobe
11794 //randomise location and face Hero
11795 224 int32_t t=0;
11796 224 bool placed=false;
11797
11798
4/4
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 367 times.
✓ Branch 2 taken 367 times.
✓ Branch 3 taken 224 times.
591 while(!placed && t<160)
11799 {
11800
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 87 times.
367 if(isdungeon(screen_spawned))
11801 {
11802 280 x=((zc_oldrand()%12)+2)*16;
11803 280 y=((zc_oldrand()%7)+2)*16;
11804 280 }
11805 else
11806 {
11807 87 x=((zc_oldrand()%14)+1)*16;
11808 87 y=((zc_oldrand()%9)+1)*16;
11809 }
11810
11811 367 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11812
11813
6/6
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 244 times.
✓ Branch 2 taken 187 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 143 times.
✓ Branch 5 taken 224 times.
611 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11814 {
11815 224 placed=true;
11816 224 }
11817
11818 367 ++t;
11819 }
11820
11821
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 163 times.
224 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11822 {
11823
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 14 times.
61 if(y<Hero.getY())
11824 {
11825 47 dir=down;
11826 47 }
11827 else
11828 {
11829 14 dir=up;
11830 }
11831 61 }
11832 else
11833 {
11834
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 72 times.
163 if(x<Hero.getX())
11835 {
11836 72 dir=right;
11837 72 }
11838 else
11839 {
11840 91 dir=left;
11841 }
11842 }
11843
11844
1/2
✓ Branch 0 taken 224 times.
✗ Branch 1 not taken.
224 if(!placed) // can't place him, he's gone
11845 return true;
11846
11847
11848 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
11849 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
11850 224 }
11851 4486 else place_on_axis(true, dmisc4!=0);
11852 5123 }
11853 else
11854 {
11855 1117 int32_t t=0;
11856 1117 bool placed=false;
11857
11858
4/4
✓ Branch 0 taken 1117 times.
✓ Branch 1 taken 2443 times.
✓ Branch 2 taken 2443 times.
✓ Branch 3 taken 1117 times.
3560 while(!placed && t<160)
11859 {
11860
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 1103 times.
2443 if(isdungeon(screen_spawned))
11861 {
11862 1340 x=((zc_oldrand()%12)+2)*16;
11863 1340 y=((zc_oldrand()%7)+2)*16;
11864 1340 }
11865 else
11866 {
11867 1103 x=((zc_oldrand()%14)+1)*16;
11868 1103 y=((zc_oldrand()%9)+1)*16;
11869 }
11870
11871 2443 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
11872
11873
6/6
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 1313 times.
✓ Branch 2 taken 898 times.
✓ Branch 3 taken 415 times.
✓ Branch 4 taken 1326 times.
✓ Branch 5 taken 1117 times.
3756 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
11874 {
11875 1117 placed=true;
11876 1117 }
11877
11878 2443 ++t;
11879 }
11880
11881
2/2
✓ Branch 0 taken 386 times.
✓ Branch 1 taken 731 times.
1117 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
11882 {
11883
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 148 times.
386 if(y<Hero.getY())
11884 {
11885 238 dir=down;
11886 238 }
11887 else
11888 {
11889 148 dir=up;
11890 }
11891 386 }
11892 else
11893 {
11894
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 391 times.
731 if(x<Hero.getX())
11895 {
11896 340 dir=right;
11897 340 }
11898 else
11899 {
11900 391 dir=left;
11901 }
11902 }
11903
11904
1/2
✓ Branch 0 taken 1117 times.
✗ Branch 1 not taken.
1117 if(!placed) // can't place him, he's gone
11905 return true;
11906 }
11907
11908 6240 fading=fade_flicker;
11909 6240 submerge(false);
11910 6240 solid_update(false);
11911 6240 break;
11912
11913 case 64:
11914 5313 fading=0;
11915 5313 charging=true;
11916 5313 break;
11917
11918 case 73:
11919 5151 charging=false;
11920 5151 firing=40;
11921 5151 break;
11922
11923 case 83:
11924 5006 wizzrobe_attack_for_real();
11925 5006 break;
11926
11927 case 119:
11928 4247 firing=false;
11929 4247 charging=true;
11930 4247 break;
11931
11932 case 128:
11933 4109 fading=fade_flicker;
11934 4109 charging=false;
11935 4109 break;
11936
11937 case 146:
11938 3855 fading=fade_invisible;
11939 3855 submerge(true);
11940 3855 solid_update(false);
11941
11942 [[fallthrough]];
11943 default:
11944
4/4
✓ Branch 0 taken 987060 times.
✓ Branch 1 taken 160 times.
✓ Branch 2 taken 980971 times.
✓ Branch 3 taken 6249 times.
987220 if(clk>=(146+zc_max(0,dmisc5)))
11945 6249 clk=-1;
11946
11947 987220 break;
11948 }
11949 }
11950
11951 2043590 return enemy::animate(index);
11952 2081613 }
11953
11954 7929 void eWizzrobe::wizzrobe_attack_for_real()
11955 {
11956
1/2
✓ Branch 0 taken 7929 times.
✗ Branch 1 not taken.
7929 if(wpn==0) // Edited enemies
11957 return;
11958
11959
2/2
✓ Branch 0 taken 1983 times.
✓ Branch 1 taken 5946 times.
7929 if(dmisc2 == 0) //normal weapon
11960 {
11961 5946 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
11962 5946 sfx(firesfx, pan(int32_t(x)));
11963 5946 }
11964
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 988 times.
1983 else if(dmisc2 == 1) // ring of fire
11965 {
11966 995 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
11967 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11968 995 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
11969 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11970 995 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
11971 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11972 995 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
11973 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11974 995 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
11975 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11976 995 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
11977 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11978 995 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
11979 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11980 995 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
11981 995 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
11982 //this block of code was buggy and flat out doesn't match the default wpnsfx for these weapons.
11983 //i've compromised by making all old quest use this code chunk by default.
11984
1/2
✓ Branch 0 taken 995 times.
✗ Branch 1 not taken.
995 if (FFCore.quest_format[vGuys] < 51)
11985 {
11986 995 sfx(WAV_FIRE, pan(int32_t(x)));
11987
2/2
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 507 times.
995 if (get_qr(qr_8WAY_SHOT_SFX_DEP)) sfx(WAV_FIRE,pan(int32_t(x)));
11988 else
11989 {
11990
3/17
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 68 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 420 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
507 switch (wpn)
11991 {
11992 19 case ewFireball: sfx(40, pan(int32_t(x))); break;
11993 case ewBrang: sfx(4, pan(int32_t(x))); break; //Ghost.zh has 0?
11994 case ewSword: sfx(20, pan(int32_t(x))); break; //Ghost.zh has 0?
11995 case ewRock: sfx(51, pan(int32_t(x))); break;
11996 68 case ewMagic: sfx(32, pan(int32_t(x))); break;
11997 case ewBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
11998 case ewSBomb: sfx(3, pan(int32_t(x))); break; //Ghost.zh has 0?
11999 case ewLitBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12000 case ewLitSBomb: sfx(21, pan(int32_t(x))); break; //Ghost.zh has 0?
12001 case ewFireTrail: sfx(13, pan(int32_t(x))); break;
12002 420 case ewFlame: sfx(13, pan(int32_t(x))); break;
12003 case ewWind: sfx(32, pan(int32_t(x))); break;
12004 case ewFlame2: sfx(13, pan(int32_t(x))); break;
12005 case ewFlame2Trail: sfx(13, pan(int32_t(x))); break;
12006 case ewIce: sfx(44, pan(int32_t(x))); break;
12007 case ewFireball2: sfx(40, pan(int32_t(x))); break; //fireball (rising)
12008 default: sfx(WAV_FIRE, pan(int32_t(x))); break;
12009 }
12010 }
12011 995 }
12012 else
12013 {
12014 sfx(firesfx, pan(int32_t(x)));
12015 }
12016 995 }
12017
2/2
✓ Branch 0 taken 971 times.
✓ Branch 1 taken 17 times.
988 else if(dmisc2==2) // summons specific enemy
12018 {
12019 971 int32_t bc=0;
12020
12021
2/2
✓ Branch 0 taken 10497 times.
✓ Branch 1 taken 971 times.
11468 for(int32_t gc=0; gc<guys.Count(); gc++)
12022 {
12023
2/2
✓ Branch 0 taken 5302 times.
✓ Branch 1 taken 5195 times.
10497 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12024 {
12025 5195 ++bc;
12026 5195 }
12027 10497 }
12028
12029
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 963 times.
971 if(bc<=40)
12030 {
12031 963 int32_t kids = guys.Count();
12032 963 int32_t bats=(zc_oldrand()%3)+1;
12033
12034
2/2
✓ Branch 0 taken 1965 times.
✓ Branch 1 taken 963 times.
2928 for(int32_t i=0; i<bats; i++)
12035 {
12036 // Summon bats (or anything)
12037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1965 times.
1965 if(addchild(screen_spawned, x,y,dmisc3,-10, this))
12038 1965 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12039 1965 }
12040 963 sfx(firesfx, pan(int32_t(x)));
12041 963 }
12042 971 }
12043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 else if(dmisc2==3) //summon from layer
12044 {
12045
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(count_layer_enemies(screen_spawned)==0)
12046 {
12047 return;
12048 }
12049
12050 17 int32_t kids = guys.Count();
12051
12052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(kids<200)
12053 {
12054 17 int32_t newguys=(zc_oldrand()%3)+1;
12055 17 bool summoned=false;
12056
12057
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 17 times.
49 for(int32_t i=0; i<newguys; i++)
12058 {
12059 32 int32_t id2=vbound(random_layer_enemy(screen_spawned),eSTART,eMAXGUYS-1);
12060 32 int32_t x2=0;
12061 32 int32_t y2=0;
12062
12063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t k=0; k<20; ++k)
12064 {
12065 36 x2=16*((zc_oldrand()%12)+2);
12066 36 y2=16*((zc_oldrand()%7)+2);
12067
12068
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 32 times.
72 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12069 {
12070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(addchild_z(screen_spawned,x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this))
12071 {
12072 32 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12073
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
32 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & move_use_fake_z))
12074 {
12075 ((enemy*)guys.spr(kids+i))->fakez = 64;
12076 ((enemy*)guys.spr(kids+i))->z = 0;
12077 }
12078 32 }
12079
12080 32 summoned=true;
12081 32 break;
12082 }
12083 4 }
12084 32 }
12085
12086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(summoned)
12087 {
12088 17 sfx(firesfx, pan(int32_t(x)));
12089 17 }
12090 17 }
12091 17 }
12092 7929 }
12093
12094
12095 1019220 void eWizzrobe::wizzrobe_attack()
12096 {
12097
10/12
✓ Branch 0 taken 982487 times.
✓ Branch 1 taken 36733 times.
✓ Branch 2 taken 982487 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 937882 times.
✓ Branch 5 taken 44605 times.
✓ Branch 6 taken 934499 times.
✓ Branch 7 taken 3383 times.
✓ Branch 8 taken 932879 times.
✓ Branch 9 taken 1620 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 932879 times.
1019220 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12098 86341 return;
12099
12100
3/8
✓ Branch 0 taken 893341 times.
✓ Branch 1 taken 39538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 893341 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
932879 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12101 {
12102 39538 fix_coords();
12103
12104
5/5
✓ Branch 0 taken 5496 times.
✓ Branch 1 taken 1050 times.
✓ Branch 2 taken 16081 times.
✓ Branch 3 taken 13008 times.
✓ Branch 4 taken 3903 times.
39538 switch(misc)
12105 {
12106 case 1: //walking
12107
2/2
✓ Branch 0 taken 10364 times.
✓ Branch 1 taken 2644 times.
13008 if(!m_walkflag(x,y,spw_door, dir))
12108 2644 misc=0;
12109 else
12110 {
12111 10364 clk3=16;
12112
12113
2/2
✓ Branch 0 taken 8966 times.
✓ Branch 1 taken 1398 times.
10364 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12114 {
12115 1398 wizzrobe_newdir(0);
12116 1398 }
12117 }
12118
12119 13008 break;
12120
12121 case 2: //phasing
12122 {
12123 3903 int32_t jx=x;
12124 3903 int32_t jy=y;
12125 3903 int32_t jdir=-1;
12126
12127
5/5
✓ Branch 0 taken 1973 times.
✓ Branch 1 taken 484 times.
✓ Branch 2 taken 472 times.
✓ Branch 3 taken 482 times.
✓ Branch 4 taken 492 times.
3903 switch(zc_oldrand()&7)
12128 {
12129 case 0:
12130 484 jx-=32;
12131 484 jy-=32;
12132 484 jdir=15;
12133 484 break;
12134
12135 case 1:
12136 472 jx+=32;
12137 472 jy-=32;
12138 472 jdir=9;
12139 472 break;
12140
12141 case 2:
12142 482 jx+=32;
12143 482 jy+=32;
12144 482 jdir=11;
12145 482 break;
12146
12147 case 3:
12148 492 jx-=32;
12149 492 jy+=32;
12150 492 jdir=13;
12151 492 break;
12152 }
12153
12154
10/10
✓ Branch 0 taken 1930 times.
✓ Branch 1 taken 1973 times.
✓ Branch 2 taken 1724 times.
✓ Branch 3 taken 206 times.
✓ Branch 4 taken 1597 times.
✓ Branch 5 taken 127 times.
✓ Branch 6 taken 1385 times.
✓ Branch 7 taken 212 times.
✓ Branch 8 taken 1140 times.
✓ Branch 9 taken 245 times.
3903 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12155 {
12156 1140 misc=3;
12157 1140 clk3=32;
12158 1140 dir=jdir;
12159 1140 break;
12160 }
12161 2763 }
12162 [[fallthrough]];
12163 case 3:
12164 3813 dir&=3;
12165 3813 misc=0;
12166 [[fallthrough]];
12167 case 0:
12168 19894 wizzrobe_newdir(64);
12169 [[fallthrough]];
12170 default:
12171
2/2
✓ Branch 0 taken 21886 times.
✓ Branch 1 taken 3504 times.
25390 if(!canmove(dir,(zfix)1,spw_door,false))
12172 {
12173
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 239 times.
3504 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12174 {
12175 3265 misc=1;
12176 3265 clk3=16;
12177 3265 }
12178 else
12179 {
12180 239 wizzrobe_newdir(64);
12181 239 misc=0;
12182 239 clk3=32;
12183 }
12184 3504 }
12185 else
12186 {
12187 21886 clk3=32;
12188 }
12189
12190 25390 break;
12191 }
12192
12193
2/2
✓ Branch 0 taken 35060 times.
✓ Branch 1 taken 4478 times.
39538 if(misc<0)
12194 4478 ++misc;
12195 39538 }
12196
12197 932879 --clk3;
12198
12199
3/3
✓ Branch 0 taken 248377 times.
✓ Branch 1 taken 620599 times.
✓ Branch 2 taken 63903 times.
932879 switch(misc)
12200 {
12201 case 1:
12202 case 3:
12203 248377 step=1;
12204 248377 break;
12205
12206 case 2:
12207 63903 step=0;
12208 63903 break;
12209
12210 default:
12211 620599 step=0.5;
12212 620599 break;
12213
12214 }
12215
12216 932879 move(step);
12217
12218 // if(d->misc1 && misc<=0 && clk3==28)
12219
5/6
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620599 times.
✓ Branch 3 taken 312280 times.
✓ Branch 4 taken 599052 times.
✓ Branch 5 taken 21547 times.
932879 if(dmisc1 && misc<=0 && clk3==28)
12220 {
12221
2/2
✓ Branch 0 taken 16835 times.
✓ Branch 1 taken 4712 times.
21547 if(dmisc2 != 1)
12222 {
12223
2/2
✓ Branch 0 taken 14907 times.
✓ Branch 1 taken 1928 times.
16835 if(lined_up(8,false) == dir)
12224 {
12225 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12226 // sfx(WAV_WAND,pan(int32_t(x)));
12227 1928 wizzrobe_attack_for_real();
12228 1928 fclk=30;
12229 1928 }
12230 16835 }
12231 else
12232 {
12233
2/2
✓ Branch 0 taken 3717 times.
✓ Branch 1 taken 995 times.
4712 if((zc_oldrand()%500)>=400)
12234 {
12235 995 wizzrobe_attack_for_real();
12236 995 fclk=30;
12237 995 }
12238 }
12239 21547 }
12240
12241
4/4
✓ Branch 0 taken 517526 times.
✓ Branch 1 taken 415353 times.
✓ Branch 2 taken 4050 times.
✓ Branch 3 taken 513476 times.
932879 if(misc==0 && (zc_oldrand()&127)==0)
12242 4050 misc=2;
12243
12244
4/4
✓ Branch 0 taken 67953 times.
✓ Branch 1 taken 864926 times.
✓ Branch 2 taken 64512 times.
✓ Branch 3 taken 3441 times.
932879 if(misc==2 && clk3==4)
12245 3441 fix_coords();
12246
12247
2/4
✓ Branch 0 taken 932879 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 932879 times.
932879 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12248 {
12249
2/2
✓ Branch 0 taken 849597 times.
✓ Branch 1 taken 83282 times.
932879 if(fclk>0)
12250 {
12251 83282 --fclk;
12252 83282 }
12253 932879 }
12254
12255 1019220 }
12256
12257 21531 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12258 {
12259 // Wizzrobes shouldn't move to the edge of the screen;
12260 // if they're already there, they should move toward the center
12261
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21498 times.
21531 if(x<32)
12262 33 dir=right;
12263
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 21494 times.
21498 else if(x>=world_w-32)
12264 4 dir=left;
12265
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21492 times.
21494 else if(y<32)
12266 2 dir=down;
12267
2/2
✓ Branch 0 taken 21487 times.
✓ Branch 1 taken 5 times.
21492 else if(y>=world_h-32)
12268 5 dir=up;
12269 else
12270 21487 newdir(4,homing,spw_wizzrobe);
12271 21531 }
12272
12273 2099229 void eWizzrobe::draw(BITMAP *dest)
12274 {
12275 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12276
13/14
✓ Branch 0 taken 1042483 times.
✓ Branch 1 taken 1056746 times.
✓ Branch 2 taken 817873 times.
✓ Branch 3 taken 224610 times.
✓ Branch 4 taken 132112 times.
✓ Branch 5 taken 910371 times.
✓ Branch 6 taken 130752 times.
✓ Branch 7 taken 1360 times.
✓ Branch 8 taken 129926 times.
✓ Branch 9 taken 826 times.
✓ Branch 10 taken 125018 times.
✓ Branch 11 taken 4908 times.
✓ Branch 12 taken 125018 times.
✗ Branch 13 not taken.
2099229 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12277 125018 return;
12278
12279 1974211 int32_t tempint=dummy_int[1];
12280 1974211 bool tempbool1=dummy_bool[1];
12281 1974211 bool tempbool2=dummy_bool[2];
12282 1974211 dummy_int[1]=fclk;
12283 1974211 dummy_bool[1]=charging;
12284 1974211 dummy_bool[2]=firing;
12285 1974211 update_enemy_frame();
12286 1974211 dummy_int[1]=tempint;
12287 1974211 dummy_bool[1]=tempbool1;
12288 1974211 dummy_bool[2]=tempbool2;
12289 1974211 enemy::draw(dest);
12290 2099229 }
12291
12292 203 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12293 203 {
12294 203 fading=fade_flash_die;
12295
6/8
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 154 times.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✓ Branch 7 taken 46 times.
203 if(dir==down&&y>=128)
12296 {
12297 3 dir=up;
12298 3 }
12299
12300
5/8
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 141 times.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 62 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 62 times.
203 if(dir==right&&x>=208)
12301 {
12302 dir=left;
12303 }
12304
1/4
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
203 if (SIZEflags != 0) init_size_flags();;
12305 203 }
12306
12307 125855 bool eDodongo::animate(int32_t index)
12308 {
12309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125855 times.
125855 if(switch_hooked) return enemy::animate(index);
12310
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 122065 times.
125855 if(dying)
12311 {
12312 3790 return Dead(index);
12313 }
12314
12315
2/2
✓ Branch 0 taken 121496 times.
✓ Branch 1 taken 569 times.
122065 if(clk==0)
12316 {
12317 569 removearmos(x,y,ffcactivated);
12318 569 }
12319
12320
2/2
✓ Branch 0 taken 10848 times.
✓ Branch 1 taken 111217 times.
122065 if(clk2) // ate a bomb
12321 {
12322
2/2
✓ Branch 0 taken 10735 times.
✓ Branch 1 taken 113 times.
10848 if(--clk2==0)
12323 113 hp-=misc; // store bomb's power in misc
12324 10848 }
12325 else
12326 111217 constant_walk(rate,homing,spw_clipright);
12327
12328 122065 hit_width = (dir<=down) ? 16 : 32;
12329 // hysz = (dir>=left) ? 16 : 32;
12330
12331 122065 return enemy::animate(index);
12332 125855 }
12333
12334 125845 void eDodongo::draw(BITMAP *dest)
12335 {
12336 125845 tile=o_tile;
12337
12338
2/2
✓ Branch 0 taken 3065 times.
✓ Branch 1 taken 122780 times.
125845 if(clk<0)
12339 {
12340 3065 enemy::drawzcboss(dest);
12341 3065 return;
12342 }
12343
12344 122780 update_enemy_frame();
12345 122780 enemy::drawzcboss(dest);
12346
12347
2/2
✓ Branch 0 taken 51662 times.
✓ Branch 1 taken 71118 times.
122780 if(dummy_int[1]!=0) //additional tiles
12348 {
12349 71118 tile+=dummy_int[1]; //second tile is previous tile
12350 71118 xofs-=16; //new xofs change
12351 71118 enemy::drawzcboss(dest);
12352 71118 xofs+=16;
12353 71118 }
12354
12355 125845 }
12356
12357 8218 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12358 {
12359 8218 int32_t wpnId = w->id;
12360 8218 int32_t power = w->power;
12361 8218 int32_t wpnx = w->x;
12362 8218 int32_t wpny = w->y;
12363
12364
5/12
✓ Branch 0 taken 8218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2457 times.
✓ Branch 5 taken 5761 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2457 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8218 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12365 5761 return 0;
12366
12367
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 803 times.
✓ Branch 2 taken 1491 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
2457 switch(wpnId)
12368 {
12369 case wPhantom:
12370 return 0;
12371
12372 case wFire:
12373 case wBait:
12374 case wWhistle:
12375 case wWind:
12376 case wSSparkle:
12377 case wFSparkle:
12378 return 0;
12379
12380 case wLitBomb:
12381 case wLitSBomb:
12382
6/6
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 537 times.
✓ Branch 2 taken 293 times.
✓ Branch 3 taken 510 times.
✓ Branch 4 taken 690 times.
✓ Branch 5 taken 113 times.
803 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12383 690 return 0;
12384
12385 113 clk2=96;
12386 113 misc=power;
12387
12388
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 3 times.
113 if(wpnId==wLitSBomb)
12389 3 item_set=isSBOMB100;
12390
12391 113 return 1;
12392
12393 case wBomb:
12394 case wSBomb:
12395
6/6
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 1071 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 975 times.
1491 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12396 516 return 0;
12397
12398 975 stunclk=160;
12399 975 misc=wpnId; // store wpnId
12400 975 return 1;
12401
12402 case wSword:
12403
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 88 times.
146 if(stunclk)
12404 {
12405 88 sfx(WAV_EHIT,pan(int32_t(x)));
12406 88 hp=0;
12407 88 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12408 88 fading=0; // don't flash
12409 88 return 1;
12410 }
12411
12412 [[fallthrough]];
12413 default:
12414 75 sfx(WAV_CHINK,pan(int32_t(x)));
12415 75 }
12416
12417 75 return 1;
12418 8218 }
12419
12420 48 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12421 48 {
12422 48 fading=fade_flash_die;
12423 //nets+5180;
12424 48 previous_dir=-1;
12425
6/8
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 13 times.
48 if(dir==down&&y>=128)
12426 {
12427 1 dir=up;
12428 1 }
12429
12430
5/8
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
48 if(dir==right&&x>=208)
12431 {
12432 dir=left;
12433 }
12434
1/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if (SIZEflags != 0) init_size_flags();;
12435 48 }
12436
12437 39398 bool eDodongo2::animate(int32_t index)
12438 {
12439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39398 times.
39398 if(switch_hooked) return enemy::animate(index);
12440
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 38240 times.
39398 if(dying)
12441 {
12442 1158 return Dead(index);
12443 }
12444
12445
2/2
✓ Branch 0 taken 38073 times.
✓ Branch 1 taken 167 times.
38240 if(clk==0)
12446 {
12447 167 removearmos(x,y,ffcactivated);
12448 167 }
12449
12450
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 34208 times.
38240 if(clk2) // ate a bomb
12451 {
12452
2/2
✓ Branch 0 taken 3990 times.
✓ Branch 1 taken 42 times.
4032 if(--clk2==0)
12453 42 hp-=misc; // store bomb's power in misc
12454 4032 }
12455 else
12456 34208 constant_walk(rate,homing,spw_clipbottomright);
12457
12458 38240 hit_width = (dir<=down) ? 16 : 32;
12459 38240 hit_height = (dir>=left) ? 16 : 32;
12460 38240 hxofs=(dir>=left)?-8:0;
12461 38240 hyofs=(dir<left)?-8:0;
12462
12463 38240 return enemy::animate(index);
12464 39398 }
12465
12466 39601 void eDodongo2::draw(BITMAP *dest)
12467 {
12468
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 38833 times.
39601 if(clk<0)
12469 {
12470 768 enemy::drawzcboss(dest);
12471 768 return;
12472 }
12473
12474 38833 int32_t tempx=xofs;
12475 38833 int32_t tempy=yofs;
12476 38833 update_enemy_frame();
12477 38833 enemy::drawzcboss(dest);
12478 38833 tile+=dummy_int[1]; //second tile change
12479 38833 xofs+=dummy_int[2]; //new xofs change
12480 38833 yofs+=dummy_int[3]; //new yofs change
12481 38833 enemy::drawzcboss(dest);
12482 38833 xofs=tempx;
12483 38833 yofs=tempy;
12484 39601 }
12485
12486 3929 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12487 {
12488 3929 int32_t wpnId = w->id;
12489 3929 int32_t power = w->power;
12490 3929 int32_t wpnx = w->x;
12491 3929 int32_t wpny = w->y;
12492
12493
5/8
✓ Branch 0 taken 3929 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3929 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1552 times.
✓ Branch 5 taken 2377 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1552 times.
3929 if(dying || clk<0 || clk2>0 || superman)
12494 2377 return 0;
12495
12496
5/6
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 693 times.
✓ Branch 3 taken 31 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 161 times.
1552 switch(wpnId)
12497 {
12498 case wPhantom:
12499 return 0;
12500
12501 case wFire:
12502 case wBait:
12503 case wWhistle:
12504 case wWind:
12505 case wSSparkle:
12506 case wFSparkle:
12507 346 return 0;
12508
12509 case wLitBomb:
12510 case wLitSBomb:
12511
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 81 times.
321 switch(dir)
12512 {
12513 case up:
12514
4/4
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 4 times.
81 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12515 77 return 0;
12516
12517 4 break;
12518
12519 case down:
12520
4/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 6 times.
77 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12521 71 return 0;
12522
12523 6 break;
12524
12525 case left:
12526
4/4
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 16 times.
82 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12527 66 return 0;
12528
12529 16 break;
12530
12531 case right:
12532
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 65 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 16 times.
81 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12533 65 return 0;
12534
12535 16 break;
12536 }
12537
12538 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12539 // return 0;
12540 42 clk2=96;
12541 42 misc=power;
12542
12543
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(wpnId==wLitSBomb)
12544 item_set=isSBOMB100;
12545
12546 42 return 1;
12547
12548 case wBomb:
12549 case wSBomb:
12550
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 176 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 185 times.
✓ Branch 4 taken 164 times.
693 switch(dir)
12551 {
12552 case up:
12553
4/4
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 92 times.
176 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12554 84 return 0;
12555
12556 92 break;
12557
12558 case down:
12559
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 87 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 55 times.
168 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12560 113 return 0;
12561
12562 55 break;
12563
12564 case left:
12565
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 105 times.
185 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12566 80 return 0;
12567
12568 105 break;
12569
12570 case right:
12571
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 93 times.
164 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12572 71 return 0;
12573
12574 93 break;
12575 }
12576
12577 345 stunclk=160;
12578 345 misc=wpnId; // store wpnId
12579 345 return 1;
12580
12581 case wSword:
12582
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 34 times.
161 if(stunclk)
12583 {
12584 34 sfx(WAV_EHIT,pan(int32_t(x)));
12585 34 hp=0;
12586 34 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12587 34 fading=0; // don't flash
12588 34 return 1;
12589 }
12590
12591 [[fallthrough]];
12592 default:
12593 158 sfx(WAV_CHINK,pan(int32_t(x)));
12594 158 }
12595
12596 158 return 1;
12597 3929 }
12598
12599 125 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12600 125 {
12601 //these are here to bypass compiler warnings about unused arguments
12602
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if ( !(editorflags & ENEMY_FLAG5) )
12603 {
12604
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 position_relative_to_screen(x, y, dmisc1 ? 64 : 176, 64);
12605 125 }
12606 else { x = X; y = Y; }
12607
12608 //nets+5940;
12609
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 44 times.
125 if(get_qr(qr_NEWENEMYTILES))
12610 {
12611 81 }
12612 else
12613 {
12614
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 7 times.
44 if(dmisc1)
12615 {
12616 7 flip=1;
12617 7 }
12618 }
12619
12620
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12621 125 clk3=32;
12622 125 clk2=0;
12623 125 clk4=clk;
12624 125 dir=left;
12625
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if (SIZEflags != 0) init_size_flags();;
12626 125 }
12627
12628 71416 bool eAquamentus::animate(int32_t index)
12629 {
12630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71416 times.
71416 if(switch_hooked) return enemy::animate(index);
12631
2/2
✓ Branch 0 taken 2074 times.
✓ Branch 1 taken 69342 times.
71416 if(dying)
12632 2074 return Dead(index);
12633
12634 // fbx=x+((id==eRAQUAM)?4:-4);
12635
2/2
✓ Branch 0 taken 69027 times.
✓ Branch 1 taken 315 times.
69342 if(clk==0)
12636 {
12637 315 removearmos(x,y,ffcactivated);
12638 315 }
12639
12640 69342 fbx=x;
12641
12642 /*
12643 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
12644 {
12645 fbx+=16;
12646 }
12647 */
12648
2/2
✓ Branch 0 taken 68896 times.
✓ Branch 1 taken 446 times.
69342 if(--clk3==0)
12649 {
12650 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
12651 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
12652 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
12653 446 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
12654 446 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
12655 446 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
12656 446 sfx(wpnsfx(wpn),pan(int32_t(x)));
12657 446 }
12658
12659
4/4
✓ Branch 0 taken 21285 times.
✓ Branch 1 taken 48057 times.
✓ Branch 2 taken 20943 times.
✓ Branch 3 taken 342 times.
69342 if(clk3<-80 && !(zc_oldrand()&63))
12660 {
12661 342 clk3=32;
12662 342 }
12663
12664 69342 int screen_x = x.getInt()%256;
12665
2/2
✓ Branch 0 taken 68233 times.
✓ Branch 1 taken 1109 times.
69342 if(!((clk4+1)&63))
12666 {
12667 1109 int32_t d2=(zc_oldrand()%3)+1;
12668
12669
2/2
✓ Branch 0 taken 362 times.
✓ Branch 1 taken 747 times.
1109 if(d2>=left)
12670 {
12671 747 dir=d2;
12672 747 }
12673
12674
2/2
✓ Branch 0 taken 724 times.
✓ Branch 1 taken 385 times.
1109 if(dmisc1)
12675 {
12676
2/2
✓ Branch 0 taken 347 times.
✓ Branch 1 taken 38 times.
385 if(screen_x<=40)
12677 {
12678 38 dir=right;
12679 38 }
12680
12681
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 if(screen_x>=104)
12682 {
12683 dir=left;
12684 }
12685 385 }
12686 else
12687 {
12688
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 20 times.
724 if(screen_x<=136)
12689 {
12690 20 dir=right;
12691 20 }
12692
12693
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 34 times.
724 if(screen_x>=200)
12694 {
12695 34 dir=left;
12696 34 }
12697 }
12698 1109 }
12699
12700
4/4
✓ Branch 0 taken 67456 times.
✓ Branch 1 taken 1886 times.
✓ Branch 2 taken 58972 times.
✓ Branch 3 taken 8484 times.
69342 if(clk4>=-1 && !((clk4+1)&7))
12701 {
12702
2/2
✓ Branch 0 taken 4498 times.
✓ Branch 1 taken 3986 times.
8484 if(dir==left)
12703 {
12704 4498 x-=1;
12705 4498 }
12706 else
12707 {
12708 3986 x+=1;
12709 }
12710 8484 }
12711
12712 69342 clk4=(clk4+1)%256;
12713
12714 69342 return enemy::animate(index);
12715 71416 }
12716
12717 71827 void eAquamentus::draw(BITMAP *dest)
12718 {
12719
2/2
✓ Branch 0 taken 44994 times.
✓ Branch 1 taken 26833 times.
71827 if(get_qr(qr_NEWENEMYTILES))
12720 {
12721 44994 xofs=(dmisc1?-16:0);
12722
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44994 times.
✓ Branch 2 taken 18341 times.
✓ Branch 3 taken 26653 times.
44994 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
12723
12724
2/2
✓ Branch 0 taken 1312 times.
✓ Branch 1 taken 43682 times.
44994 if(dying)
12725 {
12726 1312 xofs=0;
12727 1312 enemy::draw(dest);
12728 1312 }
12729 else
12730 {
12731 43682 drawblock(dest,15);
12732 }
12733 44994 }
12734 else
12735 {
12736 26833 int32_t xblockofs=((dmisc1)?-16:16);
12737 26833 xofs=0;
12738
12739
4/4
✓ Branch 0 taken 26166 times.
✓ Branch 1 taken 667 times.
✓ Branch 2 taken 762 times.
✓ Branch 3 taken 25404 times.
26833 if(clk<0 || dying)
12740 {
12741 1429 enemy::draw(dest);
12742 1429 return;
12743 }
12744
1/2
✓ Branch 0 taken 25404 times.
✗ Branch 1 not taken.
25404 if ( do_animation )
12745 {
12746 // face (0=firing, 2=resting)
12747 25404 tile=o_tile+((clk3>0)?0:2);
12748 25404 enemy::draw(dest);
12749 // tail (
12750 25404 tile=o_tile+((clk&16)?1:3);
12751 25404 xofs=xblockofs;
12752 25404 enemy::draw(dest);
12753 // body
12754 25404 yofs+=16;
12755 25404 xofs=0;
12756 25404 tile=o_tile+((clk&16)?20:22);
12757 25404 enemy::draw(dest);
12758 25404 xofs=xblockofs;
12759 25404 tile=o_tile+((clk&16)?21:23);
12760 25404 enemy::draw(dest);
12761 25404 yofs-=16;
12762 25404 }
12763 else enemy::draw(dest);
12764 }
12765 71827 }
12766
12767 23705 bool eAquamentus::hit(weapon *w)
12768 {
12769
3/6
✓ Branch 0 taken 23705 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23705 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23705 times.
23705 if(!w->scriptcoldet || w->fallclk || w->drownclk) return false;
12770
12771
2/2
✓ Branch 0 taken 4072 times.
✓ Branch 1 taken 19633 times.
23705 switch(w->id)
12772 {
12773 case wBeam:
12774 case wRefBeam:
12775 case wMagic:
12776 4072 hit_height=32;
12777 4072 }
12778
12779
4/4
✓ Branch 0 taken 22611 times.
✓ Branch 1 taken 1094 times.
✓ Branch 2 taken 17421 times.
✓ Branch 3 taken 5190 times.
23705 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
12780 23705 hit_height=16;
12781 23705 return ret;
12782
12783 23705 }
12784
12785 93 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
12786 93 {
12787
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if ( !(editorflags & ENEMY_FLAG5) )
12788 {
12789
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 position_relative_to_screen(x, y, 128, 48);
12790 93 }
12791 else { x = X; y = Y; }
12792
12793 93 Clk=Clk;
12794
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(flags & guy_fade_flicker)
12795 {
12796 clk=0;
12797 superman = 1;
12798 fading=fade_flicker;
12799 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12800 }
12801
3/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 42 times.
93 else if(flags & guy_fade_instant)
12802 {
12803 42 clk=0;
12804 42 }
12805 93 hxofs=-16;
12806 93 hit_width=48;
12807 93 clk4=0;
12808
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12809
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 dir=zc_oldrand()%3+1;
12810
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if (SIZEflags != 0) init_size_flags();;
12811
12812 //nets+5340;
12813 93 }
12814
12815 70891 bool eGohma::animate(int32_t index)
12816 {
12817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70891 times.
70891 if(switch_hooked) return enemy::animate(index);
12818
2/2
✓ Branch 0 taken 1226 times.
✓ Branch 1 taken 69665 times.
70891 if(dying)
12819 1226 return Dead(index);
12820
12821
2/2
✓ Branch 0 taken 69629 times.
✓ Branch 1 taken 36 times.
69665 if(fading)
12822 {
12823
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 1 times.
36 if(++clk4 > 60)
12824 {
12825 35 clk4=0;
12826 35 superman=0;
12827 35 fading=0;
12828 35 clk=0;
12829
12830 35 }
12831 1 else return enemy::animate(index);
12832 35 }
12833
12834
2/2
✓ Branch 0 taken 69314 times.
✓ Branch 1 taken 350 times.
69664 if(clk==0)
12835 {
12836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 if (ffcactivated) removearmosffc(*ffcactivated);
12837 else
12838 {
12839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 350 times.
350 removearmos(zc_max(x-16, 0_zf),y);
12840 350 did_armos = false;
12841 350 removearmos(x,y);
12842 350 did_armos = false;
12843
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 removearmos(zc_min(x+16, 255_zf),y);
12844 }
12845 350 }
12846
12847
2/2
✓ Branch 0 taken 68878 times.
✓ Branch 1 taken 786 times.
69664 if(clk<0) return enemy::animate(index);
12848
12849 // Movement clk must be separate from animation clk because of the Clock item
12850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68878 times.
68878 if(!watch)
12851 68878 clk4++;
12852
12853
2/2
✓ Branch 0 taken 67846 times.
✓ Branch 1 taken 1032 times.
68878 if((clk4&63)==0)
12854 {
12855
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 486 times.
1032 if(clk4&64)
12856 546 dir^=1;
12857 else
12858 486 dir=zc_oldrand()%3+1;
12859 1032 }
12860
12861
2/2
✓ Branch 0 taken 67761 times.
✓ Branch 1 taken 1117 times.
68878 if((clk&63)==3)
12862 {
12863
2/2
✓ Branch 0 taken 882 times.
✓ Branch 1 taken 235 times.
1117 switch(dmisc1)
12864 {
12865 case 1:
12866 235 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
12867 235 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12868 235 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
12869 235 sfx(wpnsfx(wpn),pan(int32_t(x)));
12870 235 break;
12871
12872 default:
12873
3/4
✓ Branch 0 taken 882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 754 times.
882 if(dmisc1 != 1 && dmisc1 != 2)
12874 {
12875 754 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
12876 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12877 754 sfx(wpnsfx(wpn),pan(int32_t(x)));
12878 754 }
12879
12880 882 break;
12881 }
12882 1117 }
12883
12884
6/6
✓ Branch 0 taken 8027 times.
✓ Branch 1 taken 60851 times.
✓ Branch 2 taken 7611 times.
✓ Branch 3 taken 416 times.
✓ Branch 4 taken 5396 times.
✓ Branch 5 taken 2215 times.
68878 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
12885 {
12886
2/2
✓ Branch 0 taken 290 times.
✓ Branch 1 taken 1925 times.
2215 if(!(clk3%8))
12887 {
12888 290 FireBreath(true);
12889 290 }
12890 2215 }
12891
12892
2/2
✓ Branch 0 taken 34399 times.
✓ Branch 1 taken 34479 times.
68878 if(clk4&1)
12893 34479 move((zfix)1);
12894
12895
2/2
✓ Branch 0 taken 68728 times.
✓ Branch 1 taken 150 times.
68878 if(++clk3>=400)
12896 150 clk3=0;
12897
12898 68878 return enemy::animate(index);
12899 70891 }
12900
12901 70889 void eGohma::draw(BITMAP *dest)
12902 {
12903 70889 tile=o_tile;
12904
12905
4/4
✓ Branch 0 taken 70103 times.
✓ Branch 1 taken 786 times.
✓ Branch 2 taken 1226 times.
✓ Branch 3 taken 68877 times.
70889 if(clk<0 || dying)
12906 {
12907 2012 enemy::drawzcboss(dest);
12908 2012 return;
12909 }
12910
12911
2/2
✓ Branch 0 taken 53472 times.
✓ Branch 1 taken 15405 times.
68877 if(get_qr(qr_NEWENEMYTILES))
12912 {
12913 ///if ( do_animation )
12914 //Yuck. Gohma can just not have this capability right now.
12915 // left side
12916 53472 xofs=-16;
12917 53472 flip=0;
12918 // if(clk&16) tile=180;
12919 // else { tile=182; flip=1; }
12920 53472 tile+=(3*((clk&48)>>4));
12921 53472 enemy::drawzcboss(dest);
12922
12923 // right side
12924 53472 xofs=16;
12925 // tile=(180+182)-tile;
12926 53472 tile=o_tile;
12927 53472 tile+=(3*((clk&48)>>4))+2;
12928 53472 enemy::drawzcboss(dest);
12929
12930 // body
12931 53472 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
12932 53472 tile=o_tile;
12933
12934 // tile+=(3*((clk&24)>>3))+2;
12935
2/2
✓ Branch 0 taken 2975 times.
✓ Branch 1 taken 50497 times.
53472 if(clk3<16)
12936 2975 tile+=7;
12937
2/2
✓ Branch 0 taken 15890 times.
✓ Branch 1 taken 34607 times.
50497 else if(clk3<116)
12938 15890 tile+=10;
12939
2/2
✓ Branch 0 taken 2051 times.
✓ Branch 1 taken 32556 times.
34607 else if(clk3<132)
12940 2051 tile+=7;
12941 else
12942 32556 tile+=((clk3-132)&24)?4:1;
12943
12944 53472 enemy::drawzcboss(dest);
12945
12946 53472 }
12947 else
12948 {
12949 // left side
12950 15405 xofs=-16;
12951 15405 flip=0;
12952
12953
2/2
✓ Branch 0 taken 7615 times.
✓ Branch 1 taken 7790 times.
15405 if(!(clk&16))
12954 {
12955 7790 tile+=2;
12956 7790 flip=1;
12957 7790 }
12958
12959 15405 enemy::draw(dest);
12960
12961 // right side
12962 15405 tile=o_tile;
12963 15405 xofs=16;
12964
12965
2/2
✓ Branch 0 taken 7790 times.
✓ Branch 1 taken 7615 times.
15405 if((clk&16)) tile+=2;
12966
12967 // tile=(180+182)-tile;
12968 15405 enemy::draw(dest);
12969
12970 // body
12971 15405 tile=o_tile;
12972 15405 xofs=0;
12973
12974
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 14493 times.
15405 if(clk3<16)
12975 912 tile+=4;
12976
2/2
✓ Branch 0 taken 4882 times.
✓ Branch 1 taken 9611 times.
14493 else if(clk3<116)
12977 4882 tile+=5;
12978
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 9026 times.
9611 else if(clk3<132)
12979 585 tile+=4;
12980 9026 else tile+=((clk3-132)&8)?3:1;
12981
12982 15405 enemy::draw(dest);
12983
12984 }
12985 70889 }
12986
12987 578 int32_t eGohma::takehit(weapon *w, weapon* realweap)
12988 {
12989 578 int32_t wpnId = w->id;
12990 578 int32_t power = w->power;
12991 578 int32_t wpnx = w->x;
12992 578 int32_t wpnDir = w->dir;
12993 578 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
12994
12995
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 421 times.
578 if(def < 0)
12996 {
12997
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 421 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 367 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 36 times.
421 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
12998 {
12999 93 sfx(WAV_CHINK,pan(int32_t(x)));
13000 93 return 1;
13001 }
13002 328 }
13003
13004 485 return enemy::takehit(w, realweap);
13005 578 }
13006
13007 326 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13008 326 {
13009 326 count_enemy=(id==(id&0xFFF));
13010 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13011
1/4
✓ Branch 0 taken 326 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
326 if (SIZEflags != 0) init_size_flags();;
13012 326 }
13013
13014 122944 bool eLilDig::animate(int32_t index)
13015 {
13016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 122944 times.
122944 if(switch_hooked) return enemy::animate(index);
13017
2/2
✓ Branch 0 taken 4392 times.
✓ Branch 1 taken 118552 times.
122944 if(dying)
13018 4392 return Dead(index);
13019
13020
2/2
✓ Branch 0 taken 7015 times.
✓ Branch 1 taken 111537 times.
118552 if(clk==0)
13021 {
13022 7015 removearmos(x,y,ffcactivated);
13023 7015 }
13024
13025
2/2
✓ Branch 0 taken 80035 times.
✓ Branch 1 taken 38517 times.
118552 if(misc<=128)
13026 {
13027
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 37360 times.
38517 if(!(++misc&31))
13028 1157 step+=0.25;
13029 38517 }
13030
13031 118552 variable_walk_8(rate,homing,hrate,spw_floater);
13032 118552 return enemy::animate(index);
13033 122944 }
13034
13035 123163 void eLilDig::draw(BITMAP *dest)
13036 {
13037 123163 tile = o_tile;
13038 // tile = 160;
13039 123163 int32_t fdiv = frate/4;
13040
1/2
✓ Branch 0 taken 123163 times.
✗ Branch 1 not taken.
123163 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13041
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 31706 times.
123163 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13042 123163 efrate:((clk>=(frate>>1))?1:0);
13043
13044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123163 times.
123163 if ( do_animation )
13045 {
13046
2/2
✓ Branch 0 taken 91457 times.
✓ Branch 1 taken 31706 times.
123163 if(get_qr(qr_NEWENEMYTILES))
13047 {
13048
9/9
✓ Branch 0 taken 11370 times.
✓ Branch 1 taken 10699 times.
✓ Branch 2 taken 10722 times.
✓ Branch 3 taken 12015 times.
✓ Branch 4 taken 10070 times.
✓ Branch 5 taken 9554 times.
✓ Branch 6 taken 8255 times.
✓ Branch 7 taken 10033 times.
✓ Branch 8 taken 8739 times.
91457 switch(dir-8) //directions get screwed up after 8. *shrug*
13049 {
13050 case up: //u
13051 11370 flip=0;
13052 11370 break;
13053
13054 case l_up: //d
13055 10699 flip=0;
13056 10699 tile+=4;
13057 10699 break;
13058
13059 case l_down: //l
13060 10722 flip=0;
13061 10722 tile+=8;
13062 10722 break;
13063
13064 case left: //r
13065 12015 flip=0;
13066 12015 tile+=12;
13067 12015 break;
13068
13069 case r_down: //ul
13070 10070 flip=0;
13071 10070 tile+=20;
13072 10070 break;
13073
13074 case down: //ur
13075 9554 flip=0;
13076 9554 tile+=24;
13077 9554 break;
13078
13079 case r_up: //dl
13080 8255 flip=0;
13081 8255 tile+=28;
13082 8255 break;
13083
13084 case right: //dr
13085 10033 flip=0;
13086 10033 tile+=32;
13087 10033 break;
13088 }
13089
13090 91457 tile+=f2;
13091 91457 }
13092 else
13093 {
13094 31706 tile+=(clk>=6)?1:0;
13095 }
13096 123163 }
13097
13098 123163 enemy::draw(dest);
13099 123163 }
13100
13101 79 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13102 79 {
13103
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 init_size_flags();
13104 79 }
13105
13106 29528 bool eBigDig::animate(int32_t index)
13107 {
13108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29528 times.
29528 if(switch_hooked) return enemy::animate(index);
13109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29528 times.
29528 if(dying)
13110 return Dead(index);
13111
13112
2/2
✓ Branch 0 taken 25444 times.
✓ Branch 1 taken 4084 times.
29528 if(clk==0)
13113 {
13114 4084 removearmos(x,y,ffcactivated);
13115 4084 }
13116
13117
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29402 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 63 times.
29528 switch(misc)
13118 {
13119 case 0:
13120 29402 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13121 29402 break;
13122
13123 case 1:
13124 63 ++misc;
13125 63 break;
13126
13127 case 2:
13128
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 63 times.
173 for(int32_t i=0; i<dmisc5; i++)
13129 {
13130 110 addenemy(screen_spawned,x,y,dmisc1+0x1000,-15);
13131 110 }
13132
13133
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 63 times.
93 for(int32_t i=0; i<dmisc6; i++)
13134 {
13135 30 addenemy(screen_spawned,x,y,dmisc2+0x1000,-15);
13136 30 }
13137
13138
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 63 times.
93 for(int32_t i=0; i<dmisc7; i++)
13139 {
13140 30 addenemy(screen_spawned,x,y,dmisc3+0x1000,-15);
13141 30 }
13142
13143
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 63 times.
93 for(int32_t i=0; i<dmisc8; i++)
13144 {
13145 30 addenemy(screen_spawned,x,y,dmisc4+0x1000,-15);
13146 30 }
13147
13148
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 2 times.
63 if(itemguy) // Hand down the carried item
13149 {
13150 2 int guycarryingitem = guys.Count()-1;
13151 2 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13152 2 itemguy = false;
13153 2 }
13154
13155 63 stop_bgsfx(index);
13156
13157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13158
13159 63 return true;
13160 }
13161
13162 29465 return enemy::animate(index);
13163 29528 }
13164
13165 29524 void eBigDig::draw(BITMAP *dest)
13166 {
13167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29524 times.
29524 if(anim!=aDIG)
13168 {
13169 update_enemy_frame();
13170 xofs-=8;
13171 yofs-=8;
13172 drawblock(dest,15);
13173 xofs+=8;
13174 yofs+=8;
13175 return;
13176 }
13177
13178 29524 tile = o_tile;
13179 29524 int32_t fdiv = frate/4;
13180
1/2
✓ Branch 0 taken 29524 times.
✗ Branch 1 not taken.
29524 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13181
13182
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13363 times.
29524 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13183 29524 efrate:((clk>=(frate>>1))?1:0);
13184
13185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29524 times.
29524 if ( do_animation )
13186 {
13187
2/2
✓ Branch 0 taken 16161 times.
✓ Branch 1 taken 13363 times.
29524 if(get_qr(qr_NEWENEMYTILES))
13188 {
13189
9/9
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 1684 times.
✓ Branch 2 taken 2031 times.
✓ Branch 3 taken 1910 times.
✓ Branch 4 taken 2041 times.
✓ Branch 5 taken 2043 times.
✓ Branch 6 taken 1514 times.
✓ Branch 7 taken 1009 times.
✓ Branch 8 taken 2241 times.
16161 switch(dir-8) //directions get screwed up after 8. *shrug*
13190 {
13191 case up: //u
13192 1688 flip=0;
13193 1688 break;
13194
13195 case l_up: //d
13196 1684 flip=0;
13197 1684 tile+=8;
13198 1684 break;
13199
13200 case l_down: //l
13201 2031 flip=0;
13202 2031 tile+=40;
13203 2031 break;
13204
13205 case left: //r
13206 1910 flip=0;
13207 1910 tile+=48;
13208 1910 break;
13209
13210 case r_down: //ul
13211 2041 flip=0;
13212 2041 tile+=80;
13213 2041 break;
13214
13215 case down: //ur
13216 2043 flip=0;
13217 2043 tile+=88;
13218
13219 2043 break;
13220
13221 case r_up: //dl
13222 1514 flip=0;
13223 1514 tile+=120;
13224 1514 break;
13225
13226 case right: //dr
13227 2241 flip=0;
13228 2241 tile+=128;
13229 2241 break;
13230 }
13231
13232 16161 tile+=(f2*2);
13233 16161 }
13234 else
13235 {
13236 13363 tile+=(f2)?0:2;
13237 13363 flip=(clk&1)?1:0;
13238 }
13239 29524 }
13240
13241 29524 xofs-=8;
13242 29524 yofs-=8;
13243 29524 drawblock(dest,15);
13244 29524 xofs+=8;
13245 29524 yofs+=8;
13246 29524 }
13247
13248 868 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13249 {
13250 868 int32_t wpnId = w->id;
13251
13252
3/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 805 times.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
868 if(wpnId==wWhistle && misc==0)
13253 {
13254 63 misc = 1;
13255 63 w->hit_pierce(this, 0, false);
13256 63 }
13257
13258 868 return 0;
13259 }
13260
13261 79 void eBigDig::init_size_flags()
13262 {
13263 79 SIZEflags = d->SIZEflags;
13264
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
79 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13265 // al_trace("Enemy txsz:%i\n", txsz);
13266
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
79 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
13267
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
79 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
13268 79 else hit_width = 32;
13269
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
79 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
13270 79 else hit_height = 32;
13271
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
79 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
13272 79 else hzsz = 16; // hard to jump.
13273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
13274 79 else hxofs = -8;
13275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
13276 79 else hyofs = -8;
13277 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13278
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = d->xofs;
13279
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
13280 {
13281 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13282 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
13283 }
13284
13285
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = d->zofs;
13286 79 }
13287
13288 13 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13289 13 {
13290 13 hxofs=hyofs=8;
13291
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (editorflags & ENEMY_FLAG3)
13292 {
13293 hxofs = 4;
13294 hyofs = 4;
13295 hit_width = 24;
13296 hit_height = 24;
13297 SIZEflags|=OVERRIDE_HIT_WIDTH;
13298 SIZEflags|=OVERRIDE_HIT_HEIGHT;
13299 }
13300 13 hzsz=16; //can't be jumped.
13301 13 clk2=70;
13302 13 misc=-1;
13303
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 mapscr* scr = get_scr(screen_spawned);
13304
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 mainguy=(!getmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (scr->flags9&fBELOWRETURN));
13305 13 }
13306
13307 18254 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
13308 {
13309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18254 times.
18254 if(dying)
13310
13311 return Dead(index);
13312
13313
2/2
✓ Branch 0 taken 18182 times.
✓ Branch 1 taken 72 times.
18254 if(clk==0)
13314 {
13315 72 removearmos(x,y,ffcactivated);
13316 72 }
13317
13318
6/7
✓ Branch 0 taken 3607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12680 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 984 times.
✓ Branch 5 taken 960 times.
✓ Branch 6 taken 10 times.
18254 switch(misc)
13319 {
13320 case -1:
13321 13 misc=0;
13322 [[fallthrough]];
13323 case 0:
13324
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 11985 times.
✓ Branch 2 taken 535 times.
✓ Branch 3 taken 173 times.
12693 if(++clk2>72 && !(zc_oldrand()&3))
13325 {
13326 173 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
13327 173 sfx(wpnsfx(wpn),pan(int32_t(x)));
13328 173 clk2=0;
13329 173 }
13330
13331 12693 Stunclk=0;
13332 12693 constant_walk(rate,homing,spw_none);
13333 12693 break;
13334
13335 case 1:
13336 case 2:
13337
2/2
✓ Branch 0 taken 3566 times.
✓ Branch 1 taken 41 times.
3607 if(--Stunclk<=0)
13338 {
13339 41 int32_t r=zc_oldrand();
13340
13341
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 17 times.
41 if(r&1)
13342 {
13343 17 y=96;
13344
13345
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 11 times.
17 if(r&2)
13346 6 x=160;
13347 else
13348 11 x=48;
13349
13350
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 8 times.
17 if(tooclose(x,y,48))
13351 8 x=208-x;
13352
13353 17 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, x, y);
13354 17 }
13355
13356 41 loadpalset(csBOSS,pSprite(d->bosspal));
13357 41 misc=0;
13358 41 }
13359
13360 3607 break;
13361
13362 case 3:
13363 {
13364
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 12 times.
984 if(hclk>0)
13365 972 break;
13366
13367 12 misc=4;
13368 12 clk=0;
13369 12 hxofs=1000;
13370 12 loadpalset(9,pSprite(spPILE));
13371 12 music_stop();
13372 12 stop_sfx(WAV_ROAR);
13373
13374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13375
13376 12 sfx(WAV_GANON);
13377 //Ganon's dustpile; fall in sideview. -Z
13378 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13379 //dustpile->miscellaneous[31] = eeGANON;
13380
6/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
12 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13381 12 item *dustpile = NULL;
13382 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
13383 12 dustpile = (item *)items.spr(items.Count() - 1);
13384 12 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
13385 12 break;
13386 }
13387
13388 case 4:
13389
2/2
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 12 times.
960 if(clk>=80)
13390 {
13391 12 misc=5;
13392
13393 //game->lvlitems[dlevel]|=liBOSS;
13394
13395 12 sfx(WAV_CLEARED);
13396 //Add the big TF over the ashes!
13397
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 12 times.
36 for(word q = 0; q < items.Count(); q++)
13398 {
13399 24 item *ashes = (item*)items.spr(q);
13400
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 12 times.
24 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
13401 {
13402 //Z_scripterrlog("Found correct dustpile!\n");
13403
4/8
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
12 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
13404 12 item *bigtriforce = NULL;
13405 12 bigtriforce = (item *)items.spr(items.Count() - 1);
13406 12 bigtriforce->linked_parent = eeGANON;
13407 12 }
13408 24 }
13409 12 }
13410
13411 960 break;
13412 10 case 5: return true;
13413 }
13414
13415 18244 return enemy::animate(index);
13416 18254 }
13417
13418
13419 964 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13420 {
13421 //these are here to bypass compiler warnings about unused arguments
13422 964 int32_t wpnId = w->id;
13423 964 int32_t power = w->power;
13424 964 int32_t enemyHitWeapon = w->parentitem;
13425
13426
3/3
✓ Branch 0 taken 714 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 166 times.
964 switch(misc)
13427 {
13428 case 0:
13429
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 53 times.
84 if(wpnId!=wSword)
13430 31 return 0;
13431
13432 53 hp-=power;
13433
13434
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 12 times.
53 if(hp>0)
13435 {
13436 41 misc=1;
13437 41 Stunclk=64;
13438 41 }
13439 else
13440 {
13441 12 loadpalset(csBOSS,pSprite(spBROWN));
13442 12 misc=2;
13443 12 Stunclk=284;
13444 12 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13445 }
13446
13447 53 sfx(WAV_EHIT,pan(int32_t(x)));
13448
13449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13450
13451 53 return 1;
13452
13453 case 2:
13454
4/6
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
166 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
13455 154 return 0;
13456
13457 12 misc=3;
13458 12 hclk=81;
13459 12 loadpalset(9,pSprite(spBROWN));
13460 12 return 1;
13461 }
13462
13463 714 return 0;
13464 964 }
13465
13466 20776 void eGanon::draw(BITMAP *dest)
13467 {
13468
6/6
✓ Branch 0 taken 3608 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 983 times.
✓ Branch 3 taken 2535 times.
✓ Branch 4 taken 12680 times.
✓ Branch 5 taken 960 times.
20776 switch(misc)
13469 {
13470 case 0:
13471
2/2
✓ Branch 0 taken 9511 times.
✓ Branch 1 taken 3169 times.
12680 if((clk&3)==3)
13472 3169 tile=(zc_oldrand()%5)*2+o_tile;
13473
13474
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
13475 {
13476
13477 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13478 {
13479 int odraw = drawstyle;
13480 drawstyle = 2;
13481 drawblock(dest,15);
13482 drawstyle = odraw;
13483 }
13484 else
13485 {
13486 drawblock(dest,15);
13487 }
13488 break;
13489
13490 }
13491
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12680 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12680 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
13492 {
13493 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
13494 {
13495 int odraw = drawstyle;
13496 drawstyle = 2;
13497 drawblock(dest,15);
13498 drawstyle = odraw;
13499 }
13500 else
13501 {
13502 drawblock(dest,15);
13503 }
13504 break;
13505 }
13506
1/2
✓ Branch 0 taken 12680 times.
✗ Branch 1 not taken.
12680 if(db!=999)
13507 12680 break;
13508 [[fallthrough]];
13509 case 2:
13510
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 983 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
983 if(Stunclk<64 && (Stunclk&1))
13511 break;
13512 [[fallthrough]];
13513 case -1:
13514 3518 tile=o_tile;
13515
13516 [[fallthrough]];
13517 case 1:
13518 case 3:
13519 7126 drawblock(dest,15);
13520 7126 break;
13521
13522 case 4:
13523 960 draw_guts(dest);
13524 960 draw_flash(dest);
13525 960 break;
13526 }
13527 20776 }
13528
13529 960 void eGanon::draw_guts(BITMAP *dest)
13530 {
13531
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 204 times.
960 int32_t c = zc_min(clk>>3,8);
13532 960 tile = clk<24 ? 74 : 75;
13533 960 overtile16(dest,tile,x+8-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13534 960 overtile16(dest,tile,x+8-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13535 960 overtile16(dest,tile,x+c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13536 960 overtile16(dest,tile,x+16-c-viewport.x,y+8+playing_field_offset-viewport.y,9,0);
13537 960 overtile16(dest,tile,x+c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13538 960 overtile16(dest,tile,x+16-c-viewport.x,y+c+playing_field_offset-viewport.y,9,0);
13539 960 overtile16(dest,tile,x+c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13540 960 overtile16(dest,tile,x+16-c-viewport.x,y+16-c+playing_field_offset-viewport.y,9,0);
13541 960 }
13542
13543 960 void eGanon::draw_flash(BITMAP *dest)
13544 {
13545
13546 960 int32_t c = clk-(clk>>2);
13547 960 cs = (frame&3)+6;
13548 960 overtile16(dest,194,x+8-viewport.x,y+8-clk+playing_field_offset-viewport.y,cs,0);
13549 960 overtile16(dest,194,x+8-viewport.x,y+8+clk+playing_field_offset-viewport.y,cs,2);
13550 960 overtile16(dest,195,x+8-clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,0);
13551 960 overtile16(dest,195,x+8+clk-viewport.x,y+8+playing_field_offset-viewport.y,cs,1);
13552 960 overtile16(dest,196,x+8-c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,0);
13553 960 overtile16(dest,196,x+8+c-viewport.x,y+8-c+playing_field_offset-viewport.y,cs,1);
13554 960 overtile16(dest,196,x+8-c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,2);
13555 960 overtile16(dest,196,x+8+c-viewport.x,y+8+c+playing_field_offset-viewport.y,cs,3);
13556 960 }
13557
13558 14 void getBigTri(mapscr* scr, int32_t id2)
13559 {
13560 /*
13561 *************************
13562 * BIG TRIFORCE SEQUENCE *
13563 *************************
13564 0 BIGTRI out, WHITE flash in
13565 4 WHITE flash out, PILE cset white
13566 8 WHITE in
13567 ...
13568 188 WHITE out
13569 191 PILE cset red
13570 200 top SHUTTER opens
13571 209 bottom SHUTTER opens
13572 */
13573 14 sfx(itemsbuf[id2].playsound);
13574 14 guys.clear();
13575
13576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(itemsbuf[id2].flags & item_gamedata)
13577 {
13578 game->lvlitems[dlevel]|=liTRIFORCE;
13579 }
13580
13581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
13582
13583 14 draw_screen();
13584
13585
4/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 2688 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 2688 times.
2702 for(int32_t f=0; f<24*8 && !Quit; f++)
13586 {
13587
2/2
✓ Branch 0 taken 2674 times.
✓ Branch 1 taken 14 times.
2688 if(f==4)
13588 {
13589
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 14 times.
224 for(int32_t i=1; i<16; i++)
13590 {
13591 210 RAMpal[CSET(9)+i]=_RGB(255,255,255);
13592 210 }
13593 14 }
13594
13595
2/2
✓ Branch 0 taken 2352 times.
✓ Branch 1 taken 336 times.
2688 if((f&7)==0)
13596 {
13597
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 for(int32_t cs=2; cs<5; cs++)
13598 {
13599
2/2
✓ Branch 0 taken 15120 times.
✓ Branch 1 taken 1008 times.
16128 for(int32_t i=1; i<16; i++)
13600 {
13601 15120 RAMpal[CSET(cs)+i]=_RGB(255,255,255);
13602 15120 }
13603 1008 }
13604
13605 336 refreshpal=true;
13606 336 }
13607
13608
2/2
✓ Branch 0 taken 2352 times.
✓ Branch 1 taken 336 times.
2688 if((f&7)==4)
13609 {
13610
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
13611 else loadlvlpal(0xB);
13612 336 }
13613
13614
2/2
✓ Branch 0 taken 2674 times.
✓ Branch 1 taken 14 times.
2688 if(f==191)
13615 {
13616 14 loadpalset(9,pSprite(spPILE));
13617 14 }
13618
13619 2688 advanceframe(true);
13620 2688 }
13621
13622 //play_DmapMusic();
13623 14 playLevelMusic();
13624
13625
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
14 if(itemsbuf[id2].flags & item_flag1 && cur_screen < 128)
13626 {
13627 2 Hero.dowarp(hero_scr, 1, 0); //side warp
13628 2 }
13629 14 }
13630
13631 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
13632 617 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13633 617 {
13634
1/2
✓ Branch 0 taken 617 times.
✗ Branch 1 not taken.
617 if( !(editorflags & ENEMY_FLAG5) )
13635 {
13636
1/2
✓ Branch 0 taken 617 times.
✗ Branch 1 not taken.
617 position_relative_to_screen(x, y, 128, 48);
13637 617 }
13638 //else { x = X; y = Y; }
13639
1/2
✓ Branch 0 taken 617 times.
✗ Branch 1 not taken.
617 dir=(zc_oldrand()&7)+8;
13640 617 superman=1;
13641 617 fading=fade_invisible;
13642 617 hxofs=1000;
13643 617 segcnt=clk;
13644 617 segid=Id|0x1000;
13645 617 clk=0;
13646
1/2
✓ Branch 0 taken 617 times.
✗ Branch 1 not taken.
617 id=guys.Count();
13647
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 617 times.
✓ Branch 2 taken 617 times.
✗ Branch 3 not taken.
617 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13648 617 tile=o_tile;
13649 617 hitdir = -1;
13650 617 stickclk = 0;
13651
13652 /*
13653 if (get_qr(qr_NEWENEMYTILES))
13654 {
13655 tile=nets+1220;
13656 }
13657 else
13658 {
13659 tile=57;
13660 }
13661 */
13662 617 }
13663
13664 244296 bool eMoldorm::animate(int32_t index)
13665 {
13666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244296 times.
244296 if(switch_hooked) return enemy::animate(index);
13667 244296 int32_t max_y = isdungeon(screen_spawned) ? 100 : 100+28; //warning: Ugly hack. -Z
13668
2/2
✓ Branch 0 taken 215852 times.
✓ Branch 1 taken 28444 times.
244296 if ( y > (max_y) )
13669 {
13670 28444 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
13671 //Z_scripterrlog("Stickclk is %d\n", stickclk);
13672 28444 }
13673
2/2
✓ Branch 0 taken 243734 times.
✓ Branch 1 taken 562 times.
244296 if ( stickclk > 45 )
13674 {
13675 562 stickclk = 0;
13676 562 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
13677 562 }
13678
13679
13680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 244296 times.
244296 if(clk==0)
13681 {
13682 244296 removearmos(x,y,ffcactivated);
13683 244296 }
13684
13685
2/2
✓ Branch 0 taken 2432 times.
✓ Branch 1 taken 241864 times.
244296 if(clk2)
13686 {
13687
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 128 times.
2432 if(--clk2 == 0)
13688 {
13689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(flags&guy_never_return)
13690 128 never_return(screen_spawned, index);
13691
13692
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
128 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
13693 128 leave_item();
13694
13695 128 stop_bgsfx(index);
13696 128 return true;
13697 }
13698 2304 }
13699 else
13700 {
13701
1/2
✓ Branch 0 taken 241864 times.
✗ Branch 1 not taken.
241864 if(stunclk>0)
13702 stunclk=0;
13703 241864 constant_walk_8_old(rate,homing,spw_floater);
13704
13705
13706 241864 misc=dir;
13707
13708 // If any higher-numbered segments were killed, segcnt can be too high,
13709 // leading to a crash
13710
1/2
✓ Branch 0 taken 241864 times.
✗ Branch 1 not taken.
241864 if(index+segcnt>=guys.Count())
13711 segcnt=guys.Count()-index-1;
13712
13713
2/2
✓ Branch 0 taken 241864 times.
✓ Branch 1 taken 1121087 times.
1362951 for(int32_t i=index+1; i<index+segcnt+1; i++)
13714 {
13715 1121087 enemy* segment=((enemy*)guys.spr(i));
13716
13717 // More validation - if segcnt was wrong, this may not
13718 // actually be a Moldorm segment
13719
1/2
✓ Branch 0 taken 1121087 times.
✗ Branch 1 not taken.
1121087 if(segment->id!=segid)
13720 {
13721 segcnt=i-index-1;
13722 break;
13723 }
13724
13725
2/2
✓ Branch 0 taken 878949 times.
✓ Branch 1 taken 242138 times.
1121087 if(i==index+1)
13726 {
13727 242138 x=segment->x;
13728 242138 y=segment->y;
13729 242138 }
13730
13731 1121087 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
13732 //Script your own blasted segmented bosses!! -Z
13733 1121087 segment->setParent(this);
13734
4/4
✓ Branch 0 taken 241864 times.
✓ Branch 1 taken 879223 times.
✓ Branch 2 taken 24384 times.
✓ Branch 3 taken 217480 times.
1121087 if((i==index+segcnt)&&(i!=index+1)) //tail
13735 {
13736 217480 segment->dummy_int[1]=2;
13737 217480 }
13738 else
13739 {
13740 903607 segment->dummy_int[1]=1;
13741 }
13742
13743
2/2
✓ Branch 0 taken 878949 times.
✓ Branch 1 taken 242138 times.
1121087 if(i==index+1) //head
13744 {
13745 242138 segment->dummy_int[1]=0;
13746 242138 }
13747
13748
2/2
✓ Branch 0 taken 1120076 times.
✓ Branch 1 taken 1011 times.
1121087 if(segment->hp <= 0)
13749 {
13750 1011 int32_t offset=1;
13751
13752
2/2
✓ Branch 0 taken 1011 times.
✓ Branch 1 taken 1473 times.
2484 for(int32_t j=i; j<index+segcnt; j++)
13753 {
13754 // Triple-check
13755
1/2
✓ Branch 0 taken 1473 times.
✗ Branch 1 not taken.
1473 if(((enemy*)guys.spr(j+1))->id!=segid)
13756 {
13757 segcnt=j-index+1; // Add 1 because of --segcnt below
13758 break;
13759 }
13760 1473 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
13761 1473 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
13762 1473 }
13763
13764 1011 segment->hclk=33;
13765 1011 --segcnt;
13766 1011 --i; // Recheck the same index in case multiple segments died at once
13767 1011 }
13768 1121087 }
13769
13770
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 241736 times.
241864 if(segcnt==0)
13771 {
13772 128 clk2=19;
13773
13774 128 x=guys.spr(index+1)->x;
13775 128 y=guys.spr(index+1)->y;
13776 128 }
13777 }
13778
13779 244168 return false;
13780 244296 }
13781
13782 3145 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13783 3145 {
13784
1/2
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
3145 if( !(editorflags & ENEMY_FLAG5) )
13785 {
13786
1/2
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
3145 position_relative_to_screen(x, y, 128, 48);
13787 3145 }
13788
13789
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3145 times.
✓ Branch 2 taken 3145 times.
✗ Branch 3 not taken.
3145 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
13790 3145 hyofs=4;
13791 3145 hit_width=hit_height=8;
13792 3145 hxofs=1000;
13793 3145 mainguy=count_enemy=false;
13794 3145 parentclk = 0;
13795 3145 bgsfx=-1;
13796
2/4
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3145 times.
✗ Branch 3 not taken.
3145 flags&=~guy_never_return;
13797 //deadsfx = WAV_EDEAD;
13798 3145 isCore = false;
13799 3145 }
13800
13801 1136740 bool esMoldorm::animate(int32_t index)
13802 {
13803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1136740 times.
1136740 if(switch_hooked) return enemy::animate(index);
13804 // Shouldn't be possible, but better to be sure
13805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1136740 times.
1136740 if(index==0)
13806 dying=true;
13807
13808
2/2
✓ Branch 0 taken 15653 times.
✓ Branch 1 taken 1121087 times.
1136740 if(dying)
13809 {
13810
1/2
✓ Branch 0 taken 15653 times.
✗ Branch 1 not taken.
15653 if(!dmisc2)
13811 15653 item_set=0;
13812
13813 15653 return Dead(index);
13814 }
13815
13816
2/2
✓ Branch 0 taken 104917 times.
✓ Branch 1 taken 1016170 times.
1121087 if(clk>=0)
13817 {
13818 1016170 hxofs=4;
13819 1016170 step=((enemy*)guys.spr(index-1))->step;
13820
13821
2/2
✓ Branch 0 taken 70387 times.
✓ Branch 1 taken 945783 times.
1016170 if(parentclk == 0)
13822 {
13823 70387 misc=dir;
13824 70387 dir=((enemy*)guys.spr(index-1))->misc;
13825 //do alignment, as in parent's animation :-/ -DD
13826 70387 x.doFloor();
13827 70387 y.doFloor();
13828 70387 }
13829
13830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1016170 times.
1016170 if(step)
13831 1016170 parentclk=(parentclk+1)%((int32_t)(8.0/step));
13832
13833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1016170 times.
1016170 if(!watch)
13834 {
13835 1016170 sprite::move(step);
13836 1016170 }
13837 1016170 }
13838
13839 1121087 return enemy::animate(index);
13840 1136740 }
13841
13842 2673 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
13843 {
13844
2/2
✓ Branch 0 taken 2220 times.
✓ Branch 1 taken 453 times.
2673 if(enemy::takehit(w,realweap))
13845 2220 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
13846
13847 453 return 0;
13848 2673 }
13849
13850 1154029 void esMoldorm::draw(BITMAP *dest)
13851 {
13852 1154029 tile=o_tile;
13853 1154029 int32_t fdiv = frate/4;
13854
1/2
✓ Branch 0 taken 1154029 times.
✗ Branch 1 not taken.
1154029 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13855
13856
2/2
✓ Branch 0 taken 1043930 times.
✓ Branch 1 taken 110099 times.
1154029 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13857 1154029 efrate:((clk>=(frate>>1))?1:0);
13858
13859
2/2
✓ Branch 0 taken 110099 times.
✓ Branch 1 taken 1043930 times.
1154029 if(get_qr(qr_NEWENEMYTILES))
13860 {
13861 1043930 tile+=dummy_int[1]*40;
13862
13863
2/2
✓ Branch 0 taken 102730 times.
✓ Branch 1 taken 941200 times.
1043930 if(dir<8)
13864 {
13865 102730 flip=0;
13866
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
13867
13868
1/2
✓ Branch 0 taken 102730 times.
✗ Branch 1 not taken.
102730 if(dir>3) // Skip to the next row for diagonals
13869 tile+=4;
13870 102730 }
13871 else
13872 {
13873
8/9
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 134534 times.
✓ Branch 2 taken 113426 times.
✓ Branch 3 taken 124800 times.
✓ Branch 4 taken 101314 times.
✓ Branch 5 taken 99043 times.
✓ Branch 6 taken 131794 times.
✓ Branch 7 taken 139759 times.
✗ Branch 8 not taken.
941200 switch(dir-8) //directions get screwed up after 8. *shrug*
13874 {
13875 case up: //u
13876 96530 flip=0;
13877 96530 break;
13878
13879 case l_up: //d
13880 134534 flip=0;
13881 134534 tile+=4;
13882 134534 break;
13883
13884 case l_down: //l
13885 113426 flip=0;
13886 113426 tile+=8;
13887 113426 break;
13888
13889 case left: //r
13890 124800 flip=0;
13891 124800 tile+=12;
13892 124800 break;
13893
13894 case r_down: //ul
13895 101314 flip=0;
13896 101314 tile+=20;
13897 101314 break;
13898
13899 case down: //ur
13900 99043 flip=0;
13901 99043 tile+=24;
13902 99043 break;
13903
13904 case r_up: //dl
13905 131794 flip=0;
13906 131794 tile+=28;
13907 131794 break;
13908
13909 case right: //dr
13910 139759 flip=0;
13911 139759 tile+=32;
13912 139759 break;
13913 }
13914 }
13915
13916 1043930 tile+=f2;
13917 1043930 }
13918
13919
2/2
✓ Branch 0 taken 106107 times.
✓ Branch 1 taken 1047922 times.
1154029 if(clk>=0)
13920 1047922 enemy::draw(dest);
13921 1154029 }
13922
13923 418 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
13924 418 {
13925
1/2
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
418 if( !(editorflags & ENEMY_FLAG5) )
13926 {
13927
1/2
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
418 position_relative_to_screen(x, y, 64, 80);
13928 418 }
13929 //else { x = X; y = Y; }
13930 //byte legaldirs = 0;
13931 418 int32_t incr = 16;
13932 //int32_t possiiblepos = 0;
13933 //int32_t positions[8] = {0};
13934
13935 //Don't spawn in pits.
13936
5/8
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 418 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 418 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 313 times.
✓ Branch 7 taken 105 times.
418 if ( m_walkflag_simple(x, y) )
13937 {
13938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 for ( ; incr < 240; incr += 16 )
13939 {
13940 //move if we spawn over a pit
13941 //check each direction
13942
7/12
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 139 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 139 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 135 times.
139 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
13943 {
13944
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
13945 }
13946
7/12
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 39 times.
✓ Branch 11 taken 96 times.
135 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
13947 {
13948
1/2
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
39 x+=incr; break;
13949 }
13950
9/16
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 96 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 96 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 96 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 64 times.
96 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
13951 {
13952
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
13953 }
13954
9/16
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 64 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 64 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 64 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 64 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✓ Branch 15 taken 60 times.
64 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
13955 {
13956
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 x+=incr; y-=incr; break;
13957 }
13958
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
13959 {
13960 y -= incr; break;
13961 }
13962
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
13963 {
13964 y+=incr; break;
13965 }
13966
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
13967 {
13968
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
13969 }
13970
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
13971 {
13972 x+=incr; y+=incr; break;
13973 }
13974 34 else continue;
13975
13976 }
13977
13978 105 }
13979
13980 418 dir=up;
13981 418 superman=1;
13982 418 fading=fade_invisible;
13983 418 hxofs=1000;
13984 418 segcnt=clk;
13985 418 clk=0;
13986 //set up move history
13987
2/2
✓ Branch 0 taken 418 times.
✓ Branch 1 taken 3046 times.
3464 for(int32_t i=0; i <= (1<<dmisc2); i++)
13988
3/6
✓ Branch 0 taken 3046 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3046 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3046 times.
✗ Branch 5 not taken.
3046 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
13989 418 }
13990
13991 230004 bool eLanmola::animate(int32_t index)
13992 {
13993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 230004 times.
230004 if(switch_hooked) return enemy::animate(index);
13994
2/2
✓ Branch 0 taken 191060 times.
✓ Branch 1 taken 38944 times.
230004 if(clk==0)
13995 {
13996 38944 removearmos(x,y,ffcactivated);
13997 38944 }
13998
13999
2/2
✓ Branch 0 taken 3553 times.
✓ Branch 1 taken 226451 times.
230004 if(clk2)
14000 {
14001
2/2
✓ Branch 0 taken 3366 times.
✓ Branch 1 taken 187 times.
3553 if(--clk2 == 0)
14002 {
14003
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 103 times.
187 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14004 84 leave_item();
14005
14006 187 stop_bgsfx(index);
14007 187 return true;
14008 }
14009
14010 3366 return false;
14011 }
14012
14013
14014 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14015 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14016 //I've added a complete movement history to this enemy to compensate -DD
14017 226451 constant_walk(rate,homing,spw_none);
14018 226451 prevState.pop_front();
14019 226451 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14020
14021 // This could cause a crash with Moldorms. I didn't see the same problem
14022 // with Lanmolas, but it looks like it ought to be possible, so here's
14023 // the same solution. - Saf
14024
1/2
✓ Branch 0 taken 226451 times.
✗ Branch 1 not taken.
226451 if(index+segcnt>=guys.Count())
14025 segcnt=guys.Count()-index-1;
14026
14027
2/2
✓ Branch 0 taken 226451 times.
✓ Branch 1 taken 943672 times.
1170123 for(int32_t i=index+1; i<index+segcnt+1; i++)
14028 {
14029 943672 enemy* segment=((enemy*)guys.spr(i));
14030
14031 // More validation in case segcnt is wrong
14032
1/2
✓ Branch 0 taken 943672 times.
✗ Branch 1 not taken.
943672 if((segment->id&0xFFF)!=(id&0xFFF))
14033 {
14034 segcnt=i-index-1;
14035 break;
14036 }
14037
14038 943672 segment->o_tile=o_tile;
14039 943672 segment->setParent(this);
14040
4/4
✓ Branch 0 taken 226451 times.
✓ Branch 1 taken 717221 times.
✓ Branch 2 taken 37177 times.
✓ Branch 3 taken 189274 times.
943672 if((i==index+segcnt)&&(i!=index+1))
14041 {
14042 189274 segment->dummy_int[1]=1; //tail
14043 189274 }
14044 else
14045 {
14046 754398 segment->dummy_int[1]=0;
14047 }
14048
14049
2/2
✓ Branch 0 taken 942513 times.
✓ Branch 1 taken 1159 times.
943672 if(segment->hp <= 0)
14050 {
14051
2/2
✓ Branch 0 taken 1159 times.
✓ Branch 1 taken 1943 times.
3102 for(int32_t j=i; j<index+segcnt; j++)
14052 {
14053 // Triple-check
14054
1/2
✓ Branch 0 taken 1943 times.
✗ Branch 1 not taken.
1943 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14055 {
14056 segcnt=j-index+1; // Add 1 because of --segcnt below
14057 break;
14058 }
14059 1943 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14060 1943 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14061 1943 }
14062
14063 1159 ((enemy*)guys.spr(i))->hclk=33;
14064 1159 --segcnt;
14065 1159 --i; // Recheck the same index in case multiple segments died at once
14066 1159 }
14067 943672 }
14068
14069
2/2
✓ Branch 0 taken 226264 times.
✓ Branch 1 taken 187 times.
226451 if(segcnt==0)
14070 {
14071 187 clk2=19;
14072 187 x=guys.spr(index+1)->x;
14073 187 y=guys.spr(index+1)->y;
14074 187 setmapflag(get_scr(screen_spawned), mTMPNORET);
14075 187 }
14076
14077 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14078 //which is... disastrous.
14079 226451 hp = 1;
14080 226451 return enemy::animate(index);
14081 230004 }
14082
14083 2257 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14084 2257 {
14085
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 if( !(editorflags & ENEMY_FLAG5) )
14086 {
14087
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 position_relative_to_screen(x, y, 64, 80);
14088 2257 }
14089 2257 int32_t incr = 16;
14090 //Don't spawn in pits.
14091
5/8
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2257 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1732 times.
✓ Branch 7 taken 525 times.
2257 if ( m_walkflag_simple(x, y) )
14092 {
14093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 for ( ; incr < 240; incr += 16 )
14094 {
14095 //move if we spawn over a pit
14096 //check each direction
14097
7/12
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 695 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 675 times.
695 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14098 {
14099
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14100 }
14101
7/12
✓ Branch 0 taken 675 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 675 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 675 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 675 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 195 times.
✓ Branch 11 taken 480 times.
675 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14102 {
14103
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 x+=incr; break;
14104 }
14105
9/16
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 480 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 480 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 480 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 480 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 480 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 320 times.
480 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14106 {
14107
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14108 }
14109
9/16
✓ Branch 0 taken 320 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 320 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 320 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 320 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 320 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✓ Branch 15 taken 300 times.
320 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14110 {
14111
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 x+=incr; y-=incr; break;
14112 }
14113
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14114 {
14115 y -= incr; break;
14116 }
14117
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14118 {
14119 y+=incr; break;
14120 }
14121
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14122 {
14123
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14124 }
14125
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14126 {
14127 x+=incr; y+=incr; break;
14128 }
14129 170 else continue;
14130
14131 }
14132
14133 525 }
14134
14135 2257 hxofs=1000;
14136 2257 hit_width=8;
14137 2257 mainguy=false;
14138 2257 count_enemy=(id<0x2000)?true:false;
14139
14140 //set up move history
14141
2/2
✓ Branch 0 taken 2257 times.
✓ Branch 1 taken 16693 times.
18950 for(int32_t i=0; i <= (1<<dmisc2); i++)
14142
3/6
✓ Branch 0 taken 16693 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16693 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16693 times.
✗ Branch 5 not taken.
16693 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14143
14144 2257 bgsfx = -1;
14145 2257 isCore = false;
14146
2/4
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
2257 flags&=~guy_never_return;
14147 2257 }
14148
14149 962659 bool esLanmola::animate(int32_t index)
14150 {
14151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 962659 times.
962659 if(switch_hooked) return enemy::animate(index);
14152 // Shouldn't be possible, but who knows
14153
2/2
✓ Branch 0 taken 962641 times.
✓ Branch 1 taken 18 times.
962659 if(index==0)
14154 18 dying=true;
14155
14156
2/2
✓ Branch 0 taken 18987 times.
✓ Branch 1 taken 943672 times.
962659 if(dying)
14157 {
14158 18987 xofs=0;
14159
14160
2/2
✓ Branch 0 taken 9861 times.
✓ Branch 1 taken 9126 times.
18987 if(!dmisc3)
14161 9126 item_set=0;
14162
14163 18987 return Dead(index);
14164 }
14165
14166
2/2
✓ Branch 0 taken 35826 times.
✓ Branch 1 taken 907846 times.
943672 if(clk>=0)
14167 {
14168 907846 hxofs=4;
14169
14170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 907846 times.
907846 if(!watch)
14171 {
14172 907846 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14173 907846 prevState.pop_front();
14174 907846 prevState.push_back(newstate);
14175 907846 x = newstate.first.first;
14176 907846 y = newstate.first.second;
14177 907846 dir = newstate.second;
14178 907846 }
14179 907846 }
14180
14181 943672 return enemy::animate(index);
14182 962659 }
14183
14184 2635 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14185 {
14186
2/2
✓ Branch 0 taken 2045 times.
✓ Branch 1 taken 590 times.
2635 if(enemy::takehit(w,realweap))
14187 2045 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14188
14189 590 return 0;
14190 2635 }
14191
14192 968027 void esLanmola::draw(BITMAP *dest)
14193 {
14194 968027 tile=o_tile;
14195 968027 int32_t fdiv = frate/4;
14196
1/2
✓ Branch 0 taken 968027 times.
✗ Branch 1 not taken.
968027 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14197
14198
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 339095 times.
968027 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14199 968027 efrate:((clk>=(frate>>1))?1:0);
14200
14201
2/2
✓ Branch 0 taken 628932 times.
✓ Branch 1 taken 339095 times.
968027 if(get_qr(qr_NEWENEMYTILES))
14202 {
14203
2/2
✓ Branch 0 taken 147165 times.
✓ Branch 1 taken 481767 times.
628932 if(id>=0x2000)
14204 {
14205 481767 tile+=20;
14206
14207
2/2
✓ Branch 0 taken 353025 times.
✓ Branch 1 taken 128742 times.
481767 if(dummy_int[1]==1)
14208 {
14209 128742 tile+=20;
14210 128742 }
14211 481767 }
14212
14213
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 141419 times.
✓ Branch 2 taken 140994 times.
✓ Branch 3 taken 159500 times.
✓ Branch 4 taken 187019 times.
628932 switch(dir)
14214 {
14215 case up:
14216 141419 flip=0;
14217 141419 break;
14218
14219 case down:
14220 140994 flip=0;
14221 140994 tile+=4;
14222 140994 break;
14223
14224 case left:
14225 159500 flip=0;
14226 159500 tile+=8;
14227 159500 break;
14228
14229 case right:
14230 187019 flip=0;
14231 187019 tile+=12;
14232 187019 break;
14233 }
14234
14235 628932 tile+=f2;
14236 628932 }
14237 else
14238 {
14239
2/2
✓ Branch 0 taken 83642 times.
✓ Branch 1 taken 255453 times.
339095 if(id>=0x2000)
14240 {
14241 255453 tile+=1;
14242 255453 }
14243 }
14244
14245
2/2
✓ Branch 0 taken 36918 times.
✓ Branch 1 taken 931109 times.
968027 if(clk>=0)
14246 931109 enemy::draw(dest);
14247 968027 }
14248
14249 150 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
14250 150 {
14251 //these are here to bypass compiler warnings about unused arguments
14252 150 Clk=Clk;
14253 150 superman=1;
14254
1/2
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
150 dir=(zc_oldrand()&7)+8;
14255 150 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
14256
14257
2/2
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 150 times.
842 for(int32_t i=0; i<armcnt; i++)
14258 692 arm[i]=i;
14259
14260 150 fading=fade_blue_poof;
14261 //nets+4680;
14262 150 adjusted=false;
14263
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
150 if (SIZEflags != 0) init_size_flags();;
14264 150 }
14265
14266 66494 bool eManhandla::animate(int32_t index)
14267 {
14268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66494 times.
66494 if(switch_hooked) return enemy::animate(index);
14269
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 65112 times.
66494 if(dying)
14270 1382 return Dead(index);
14271
14272
2/2
✓ Branch 0 taken 62641 times.
✓ Branch 1 taken 2471 times.
65112 if(clk==0)
14273 {
14274 2471 removearmos(x,y,ffcactivated);
14275 2471 }
14276
14277
14278 // check arm status, move dead ones to end of group
14279
2/2
✓ Branch 0 taken 193618 times.
✓ Branch 1 taken 65112 times.
258730 for(int32_t i=0; i<armcnt; i++)
14280 {
14281 193618 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
14282
3/4
✓ Branch 0 taken 193618 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 424 times.
✓ Branch 3 taken 193194 times.
193618 if(!cur_arm || cur_arm->dying)
14283 {
14284
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 424 times.
976 for(int32_t j=i; j<armcnt-1; j++)
14285 {
14286 552 zc_swap(arm[j],arm[j+1]);
14287 552 guys.swap(index+j+1,index+j+2);
14288 552 }
14289
2/2
✓ Branch 0 taken 337 times.
✓ Branch 1 taken 87 times.
424 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
14290 {
14291 87 leave_item();
14292 87 }
14293 424 --armcnt;
14294 424 --i;
14295 424 continue;
14296 }
14297
2/2
✓ Branch 0 taken 192502 times.
✓ Branch 1 taken 692 times.
193194 if(!adjusted)
14298 {
14299
2/2
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 184 times.
692 if(!dmisc2)
14300 {
14301 508 cur_arm->o_tile=o_tile+40;
14302 508 cur_arm->setParent(this);
14303 508 }
14304 else
14305 {
14306 184 cur_arm->o_tile=o_tile+160;
14307 184 cur_arm->setParent(this);
14308 }
14309 692 }
14310 193194 }
14311
14312 65112 adjusted=true;
14313
14314 // move or die
14315
2/2
✓ Branch 0 taken 65029 times.
✓ Branch 1 taken 83 times.
65112 if(armcnt==0)
14316 83 hp=0;
14317 else
14318 {
14319 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
14320
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
14321
1/2
✓ Branch 0 taken 65029 times.
✗ Branch 1 not taken.
65029 if (step > 4.5_zf) step = 4.5_zf;
14322 65029 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
14323
14324
2/2
✓ Branch 0 taken 53584 times.
✓ Branch 1 taken 11445 times.
65029 if(!dmisc2)
14325 {
14326
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 53584 times.
204603 for(int32_t i=0; i<armcnt; i++)
14327 {
14328
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14329 {
14330 case 0:
14331 38579 dy1=-24;
14332 38579 break;
14333
14334 case 1:
14335 36328 dy2=31;
14336 36328 break;
14337
14338 case 2:
14339 36250 dx1=-16;
14340 36250 break;
14341
14342 case 3:
14343 39862 dx2=31;
14344 39862 break;
14345 }
14346 151019 }
14347 53584 }
14348 else
14349 {
14350 11445 dx1=-8, dy1=-16, dx2=23, dy2=23;
14351
14352
2/2
✓ Branch 0 taken 42175 times.
✓ Branch 1 taken 11445 times.
53620 for(int32_t i=0; i<armcnt; i++)
14353 {
14354
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12012 times.
✓ Branch 2 taken 7730 times.
✓ Branch 3 taken 9837 times.
✓ Branch 4 taken 12596 times.
42175 switch(arm[i]&3)
14355 {
14356 case 0:
14357 12012 dy1=-32;
14358 12012 break;
14359
14360 case 1:
14361 7730 dy2=39;
14362 7730 break;
14363
14364 case 2:
14365 9837 dx1=-24;
14366 9837 break;
14367
14368 case 3:
14369 12596 dx2=39;
14370 12596 break;
14371 }
14372 42175 }
14373 }
14374
14375 65029 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
14376
14377
2/2
✓ Branch 0 taken 193194 times.
✓ Branch 1 taken 65029 times.
258223 for(int32_t i=0; i<armcnt; i++)
14378 {
14379 193194 zfix dx=(zfix)0,dy=(zfix)0;
14380
14381
2/2
✓ Branch 0 taken 151019 times.
✓ Branch 1 taken 42175 times.
193194 if(!dmisc2)
14382 {
14383
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 38579 times.
✓ Branch 2 taken 36328 times.
✓ Branch 3 taken 36250 times.
✓ Branch 4 taken 39862 times.
151019 switch(arm[i])
14384 {
14385 case 0:
14386 38579 dy=-16;
14387 38579 break;
14388
14389 case 1:
14390 36328 dy=16;
14391 36328 break;
14392
14393 case 2:
14394 36250 dx=-16;
14395 36250 break;
14396
14397 case 3:
14398 39862 dx=16;
14399 39862 break;
14400 }
14401 151019 }
14402 else
14403 {
14404
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 5447 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 4163 times.
✓ Branch 4 taken 6774 times.
✓ Branch 5 taken 6565 times.
✓ Branch 6 taken 3744 times.
✓ Branch 7 taken 5674 times.
✓ Branch 8 taken 5822 times.
42175 switch(arm[i])
14405 {
14406 case 0:
14407 5447 dy=-24;
14408 5447 dx=-8;
14409 5447 break;
14410
14411 case 1:
14412 3986 dy=24;
14413 3986 dx=8;
14414 3986 break;
14415
14416 case 2:
14417 4163 dx=-24;
14418 4163 dy=8;
14419 4163 break;
14420
14421 case 3:
14422 6774 dx=24;
14423 6774 dy=-8;
14424 6774 break;
14425
14426 case 4:
14427 6565 dy=-24;
14428 6565 dx=8;
14429 6565 break;
14430
14431 case 5:
14432 3744 dy=24;
14433 3744 dx=-8;
14434 3744 break;
14435
14436 case 6:
14437 5674 dx=-24;
14438 5674 dy=-8;
14439 5674 break;
14440
14441 case 7:
14442 5822 dx=24;
14443 5822 dy=8;
14444 5822 break;
14445 }
14446 }
14447
14448 193194 guys.spr(index+i+1)->x = x+dx;
14449 193194 guys.spr(index+i+1)->y = y+dy;
14450 193194 }
14451 }
14452
14453 65112 return enemy::animate(index);
14454 66494 }
14455
14456
14457 1751 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
14458 {
14459 1751 int32_t wpnId = w->id;
14460
14461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1751 times.
1751 if(dying)
14462 return 0;
14463
14464
3/4
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 786 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
1751 switch(wpnId)
14465 {
14466 case wBomb:
14467 case wSBomb:
14468 case wSword:
14469 case wHammer:
14470 case wWand:
14471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 786 times.
786 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14472
14473 case wLitBomb:
14474 case wLitSBomb:
14475 case wBait:
14476 case wWhistle:
14477 case wFire:
14478 case wWind:
14479 case wSSparkle:
14480 case wFSparkle:
14481 case wPhantom:
14482 1709 return 0;
14483
14484 case wHookshot:
14485 case wBrang:
14486 sfx(WAV_CHINK,pan(int32_t(x)));
14487 break;
14488
14489 default:
14490
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
14491 else sfx(WAV_CHINK,pan(int32_t(x)));
14492
14493 42 }
14494
14495 42 return 1;
14496 1751 }
14497
14498 66490 void eManhandla::draw(BITMAP *dest)
14499 {
14500 66490 tile=o_tile;
14501 66490 int32_t fdiv = frate/4;
14502
1/2
✓ Branch 0 taken 66490 times.
✗ Branch 1 not taken.
66490 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14503
14504
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14505 66490 efrate:((clk>=(frate>>1))?1:0);
14506
14507
2/2
✓ Branch 0 taken 48802 times.
✓ Branch 1 taken 17688 times.
66490 if(get_qr(qr_NEWENEMYTILES))
14508 {
14509
2/2
✓ Branch 0 taken 11308 times.
✓ Branch 1 taken 37494 times.
48802 if(!dmisc2)
14510 {
14511
8/9
✓ Branch 0 taken 4771 times.
✓ Branch 1 taken 4640 times.
✓ Branch 2 taken 4995 times.
✓ Branch 3 taken 5574 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3930 times.
✓ Branch 6 taken 3908 times.
✓ Branch 7 taken 5883 times.
✗ Branch 8 not taken.
37494 switch(dir-8) //directions get screwed up after 8. *shrug*
14512 {
14513 case up: //u
14514 4771 flip=0;
14515 4771 break;
14516
14517 case l_up: //d
14518 4640 flip=0;
14519 4640 tile+=4;
14520 4640 break;
14521
14522 case l_down: //l
14523 4995 flip=0;
14524 4995 tile+=8;
14525 4995 break;
14526
14527 case left: //r
14528 5574 flip=0;
14529 5574 tile+=12;
14530 5574 break;
14531
14532 case r_down: //ul
14533 3793 flip=0;
14534 3793 tile+=20;
14535 3793 break;
14536
14537 case down: //ur
14538 3930 flip=0;
14539 3930 tile+=24;
14540 3930 break;
14541
14542 case r_up: //dl
14543 3908 flip=0;
14544 3908 tile+=28;
14545 3908 break;
14546
14547 case right: //dr
14548 5883 flip=0;
14549 5883 tile+=32;
14550 5883 break;
14551 }
14552
14553 37494 tile+=f2;
14554 37494 enemy::draw(dest);
14555 37494 } //manhandla 2, big body
14556 else
14557 {
14558
14559
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1277 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 2242 times.
✓ Branch 4 taken 1789 times.
✓ Branch 5 taken 1345 times.
✓ Branch 6 taken 805 times.
✓ Branch 7 taken 948 times.
✓ Branch 8 taken 1542 times.
11308 switch(dir-8) //directions get screwed up after 8. *shrug*
14560 {
14561 case up: //u
14562 1277 flip=0;
14563 1277 break;
14564
14565 case l_up: //d
14566 1360 flip=0;
14567 1360 tile+=8;
14568 1360 break;
14569
14570 case l_down: //l
14571 2242 flip=0;
14572 2242 tile+=40;
14573 2242 break;
14574
14575 case left: //r
14576 1789 flip=0;
14577 1789 tile+=48;
14578 1789 break;
14579
14580 case r_down: //ul
14581 1345 flip=0;
14582 1345 tile+=80;
14583 1345 break;
14584
14585 case down: //ur
14586 805 flip=0;
14587 805 tile+=88;
14588 805 break;
14589
14590 case r_up: //dl
14591 948 flip=0;
14592 948 tile+=120;
14593 948 break;
14594
14595 case right: //dr
14596 1542 flip=0;
14597 1542 tile+=128;
14598 1542 break;
14599 }
14600
14601 11308 tile+=(f2*2);
14602 11308 xofs-=8;
14603 11308 yofs-=8;
14604 11308 drawblock(dest,15);
14605 11308 xofs+=8;
14606 11308 yofs+=8;
14607 }
14608 48802 }
14609 else
14610 {
14611
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 17173 times.
17688 if(!dmisc2)
14612 {
14613 17173 enemy::draw(dest);
14614 17173 }
14615 else
14616 {
14617 515 xofs-=8;
14618 515 yofs-=8;
14619 515 enemy::draw(dest);
14620 515 xofs+=16;
14621 515 enemy::draw(dest);
14622 515 yofs+=16;
14623 515 enemy::draw(dest);
14624 515 xofs-=16;
14625 515 enemy::draw(dest);
14626 515 xofs+=8;
14627 515 yofs-=8;
14628 }
14629 }
14630 66490 }
14631
14632 692 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14633 692 {
14634 692 id=misc=clk;
14635 692 dir = clk & 3;
14636 692 clk=0;
14637 692 mainguy=count_enemy=false;
14638 692 dummy_bool[0]=false;
14639 692 item_set=0;
14640 692 bgsfx=-1;
14641 692 deadsfx = WAV_EDEAD;
14642
2/4
✓ Branch 0 taken 692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 692 times.
✗ Branch 3 not taken.
692 flags &= (~guy_never_return);
14643 692 isCore = false;
14644
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 if (SIZEflags != 0) init_size_flags();;
14645 692 }
14646
14647 200202 bool esManhandla::animate(int32_t index)
14648 {
14649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200202 times.
200202 if(switch_hooked) return enemy::animate(index);
14650
2/2
✓ Branch 0 taken 7008 times.
✓ Branch 1 taken 193194 times.
200202 if(dying)
14651 7008 return Dead(index);
14652
14653
2/2
✓ Branch 0 taken 12404 times.
✓ Branch 1 taken 180790 times.
193194 if(clk==0)
14654 {
14655 12404 removearmos(x,y,ffcactivated);
14656 12404 }
14657
14658
2/2
✓ Branch 0 taken 165298 times.
✓ Branch 1 taken 27896 times.
193194 if(--clk2<=0)
14659 {
14660 27896 clk2=unsigned(zc_oldrand())%5+5;
14661 27896 clk3^=1;
14662 27896 }
14663
14664
2/2
✓ Branch 0 taken 1491 times.
✓ Branch 1 taken 191703 times.
193194 if(!(zc_oldrand()&127))
14665 {
14666 1491 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14667 1491 sfx(wpnsfx(wpn),pan(int32_t(x)));
14668 1491 }
14669
14670 193194 return enemy::animate(index);
14671 200202 }
14672
14673 200186 void esManhandla::draw(BITMAP *dest)
14674 {
14675 200186 tile=o_tile;
14676 200186 int32_t fdiv = frate/4;
14677
1/2
✓ Branch 0 taken 200186 times.
✗ Branch 1 not taken.
200186 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14678
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14679 200186 efrate:((clk>=(frate>>1))?1:0);
14680
14681
2/2
✓ Branch 0 taken 158716 times.
✓ Branch 1 taken 41470 times.
200186 if(get_qr(qr_NEWENEMYTILES))
14682 {
14683
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 39945 times.
✓ Branch 2 taken 36845 times.
✓ Branch 3 taken 39966 times.
✓ Branch 4 taken 41960 times.
158716 switch(misc&3)
14684 {
14685 case up:
14686 39945 break;
14687
14688 case down:
14689 36845 tile+=4;
14690 36845 break;
14691
14692 case left:
14693 39966 tile+=8;
14694 39966 break;
14695
14696 case right:
14697 41960 tile+=12;
14698 41960 break;
14699 }
14700
14701 158716 tile+=f2;
14702 158716 }
14703 else
14704 {
14705
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 12394 times.
✓ Branch 2 taken 7883 times.
✓ Branch 3 taken 8961 times.
✓ Branch 4 taken 12232 times.
41470 switch(misc&3)
14706 {
14707 case down:
14708 8961 flip=2;
14709
14710 [[fallthrough]];
14711 case up:
14712 21355 tile=(clk3)?188:189;
14713 21355 break;
14714
14715 case right:
14716 12232 flip=1;
14717 [[fallthrough]];
14718
14719 case left:
14720 20115 tile=(clk3)?186:187;
14721 20115 break;
14722 }
14723 }
14724
14725 200186 enemy::draw(dest);
14726 200186 }
14727
14728 168 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
14729 168 {
14730
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if ( !(editorflags & ENEMY_FLAG5) )
14731 {
14732
2/4
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
168 std::tie(x, y) = translate_screen_coordinates_to_world(screen_spawned, 120, 48);
14733 168 }
14734 else
14735 {
14736 if ( !(editorflags & ENEMY_FLAG6) )
14737 {
14738 x = X; y = Y;
14739 }
14740 else
14741 {
14742 x = X+8; y = Y;
14743 }
14744 }
14745 168 hzsz = 32; // can't be jumped.
14746 168 flameclk=0;
14747 168 misc=clk; // total head count
14748 168 clk3=clk; // live head count
14749 168 clk=0;
14750 168 clk2=60; // fire ball clock
14751 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
14752
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 hp=(guysbuf[id&0xFFF].attributes[1])*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
14753 168 dir = down;
14754 168 hxofs=4;
14755 168 hit_width=8;
14756 // frate=17*4;
14757 168 fading=fade_blue_poof;
14758 //nets+5420;
14759
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 35 times.
168 if(get_qr(qr_NEWENEMYTILES))
14760 {
14761 /*
14762 necktile=o_tile+8;
14763 if (dmisc3)
14764 {
14765 necktile+=8;
14766 }
14767 */
14768 133 necktile=o_tile+dmisc6;
14769 133 }
14770 else
14771 {
14772 35 necktile=s_tile;
14773 }
14774 168 }
14775
14776 155290 bool eGleeok::animate(int32_t index)
14777 {
14778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155290 times.
155290 if(switch_hooked) return enemy::animate(index);
14779
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 153091 times.
155290 if(dying)
14780 2199 return Dead(index);
14781
14782
2/2
✓ Branch 0 taken 152407 times.
✓ Branch 1 taken 684 times.
153091 if(clk==0)
14783 {
14784 684 removearmos(x,y,ffcactivated);
14785 684 }
14786
14787 // Check if a head was killed somehow...
14788
2/2
✓ Branch 0 taken 101719 times.
✓ Branch 1 taken 51372 times.
153091 if(index+1+clk3>=guys.Count())
14789 51372 clk3=guys.Count()-index-1;
14790
2/2
✓ Branch 0 taken 66050 times.
✓ Branch 1 taken 87041 times.
153091 if(index+1+misc>=guys.Count())
14791 87041 misc=guys.Count()-index-1;
14792
14793 //fix for the "kill all enemies" item
14794
2/2
✓ Branch 0 taken 153085 times.
✓ Branch 1 taken 6 times.
153091 if(hp==-1000)
14795 {
14796
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
14797 {
14798 // I haven't seen this fail, but it seems like it ought to be
14799 // possible, so I'm checking for it. - Saf
14800
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14801 break;
14802 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
14803 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
14804 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
14805 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
14806 12 }
14807
14808 6 clk3=0;
14809
14810
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
14811 {
14812
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
14813 break;
14814 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14815 12 }
14816 6 }
14817
14818
2/2
✓ Branch 0 taken 403171 times.
✓ Branch 1 taken 153091 times.
556262 for(int32_t i=0; i<clk3; i++)
14819 {
14820 403171 enemy *head = ((enemy*)guys.spr(index+i+1));
14821 403171 head->dummy_int[1]=necktile;
14822 403171 head->setParent(this);
14823
14824
2/2
✓ Branch 0 taken 320127 times.
✓ Branch 1 taken 83044 times.
403171 if(get_qr(qr_NEWENEMYTILES))
14825 {
14826 320127 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
14827 320127 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
14828 320127 }
14829 else
14830 {
14831 83044 head->dummy_int[2]=necktile+1; //connected head tile
14832 83044 head->dummy_int[3]=necktile+2; //flying head tile
14833 }
14834
14835 403171 head->dmisc5=dmisc5; //neck segments
14836
14837 /*
14838 if (dmisc3)
14839 {
14840 head->dummy_bool[0]=true;
14841 }
14842 */
14843
2/2
✓ Branch 0 taken 397516 times.
✓ Branch 1 taken 5655 times.
403171 if(head->hclk)
14844 {
14845
2/2
✓ Branch 0 taken 4427 times.
✓ Branch 1 taken 1228 times.
5655 if(hclk==0)
14846 {
14847 1228 hp -= 1000 - head->hp;
14848 1228 hclk = 33;
14849
14850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1228 times.
1228 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
14851
14852 1228 sfx(WAV_EHIT,pan(int32_t(head->x)));
14853 1228 }
14854
14855 5655 head->hclk = 0;
14856 5655 }
14857
14858 // Must be set in case of naughty ZScripts
14859 403171 head->hp = 1000;
14860 403171 }
14861
14862
2/2
✓ Branch 0 taken 152676 times.
✓ Branch 1 taken 415 times.
153091 if(hp<=(guysbuf[id&0xFFF].attributes[1]) * (clk3 - 1) * game->get_hero_dmgmult())
14863 {
14864 415 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
14865 415 hp=(guysbuf[id&0xFFF].attributes[1])*(--clk3)*game->get_hero_dmgmult();
14866 415 }
14867
14868
2/2
✓ Branch 0 taken 57409 times.
✓ Branch 1 taken 95682 times.
153091 if(!dmisc3)
14869 {
14870
4/4
✓ Branch 0 taken 5291 times.
✓ Branch 1 taken 90391 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 4004 times.
95682 if(++clk2>72 && !(zc_oldrand()&3))
14871 {
14872 1287 int32_t i = zc::math::SafeMod(zc_oldrand(), misc);
14873 1287 enemy *head = ((enemy*)guys.spr(index+i+1));
14874 1287 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
14875 1287 sfx(wpnsfx(wpn),pan(int32_t(x)));
14876 1287 clk2=0;
14877 1287 }
14878 95682 }
14879 else
14880 {
14881
4/4
✓ Branch 0 taken 2357 times.
✓ Branch 1 taken 55052 times.
✓ Branch 2 taken 1800 times.
✓ Branch 3 taken 557 times.
57409 if(++clk2>100 && !(zc_oldrand()&3))
14882 {
14883 557 enemy *head = ((enemy*)guys.spr(zc::math::SafeMod(zc_oldrand(), misc) + index + 1));
14884 557 head->timer=zc_oldrand()%50+50;
14885 557 clk2=0;
14886 557 }
14887 }
14888
14889
3/4
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 152964 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
153091 if((hp<=0 && !immortal))
14890 {
14891
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 127 times.
517 for(int32_t i=0; i<misc; i++)
14892 390 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
14893
14894
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(flags&guy_never_return) never_return(screen_spawned, index);
14895 127 }
14896
14897 153091 return enemy::animate(index);
14898 155290 }
14899
14900 1239 int32_t eGleeok::takehit(weapon*,weapon*)
14901 {
14902 1239 return 0;
14903 }
14904
14905 156918 void eGleeok::draw(BITMAP *dest)
14906 {
14907 156918 tile=o_tile;
14908
14909
2/2
✓ Branch 0 taken 2199 times.
✓ Branch 1 taken 154719 times.
156918 if(dying)
14910 {
14911 2199 enemy::draw(dest);
14912 2199 return;
14913 }
14914
14915 154719 int32_t f=clk/17;
14916
14917
2/2
✓ Branch 0 taken 120524 times.
✓ Branch 1 taken 34195 times.
154719 if(get_qr(qr_NEWENEMYTILES))
14918 {
14919 // body
14920 120524 xofs=-8;
14921 120524 yofs=32;
14922
14923
4/4
✓ Branch 0 taken 92588 times.
✓ Branch 1 taken 9155 times.
✓ Branch 2 taken 10095 times.
✓ Branch 3 taken 8686 times.
120524 switch(f)
14924
14925 {
14926 case 0:
14927 9155 tile+=0;
14928 9155 break;
14929
14930 case 1:
14931 10095 tile+=2;
14932 10095 break;
14933
14934 case 2:
14935 8686 tile+=4;
14936 8686 break;
14937
14938 default:
14939 92588 tile+=6;
14940 92588 break;
14941 }
14942 120524 }
14943 else
14944 {
14945 // body
14946 34195 xofs=-8;
14947 34195 yofs=32;
14948
14949
3/3
✓ Branch 0 taken 29222 times.
✓ Branch 1 taken 2514 times.
✓ Branch 2 taken 2459 times.
34195 switch(f)
14950 {
14951 case 0:
14952 2514 tile+=0;
14953 2514 break;
14954
14955 case 2:
14956 2459 tile+=4;
14957 2459 break;
14958
14959 default:
14960 29222 tile+=2;
14961 29222 break;
14962 }
14963 }
14964
14965 154719 enemy::drawblock(dest,15);
14966 156918 }
14967
14968 156918 void eGleeok::draw2(BITMAP *dest)
14969 {
14970 // the neck stub
14971 156918 tile=necktile;
14972 156918 xofs=0;
14973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156918 times.
156918 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14974
14975
2/2
✓ Branch 0 taken 34737 times.
✓ Branch 1 taken 122181 times.
156918 if(get_qr(qr_NEWENEMYTILES))
14976 {
14977 122181 tile+=((clk&24)>>3);
14978 122181 }
14979
14980
3/4
✓ Branch 0 taken 154719 times.
✓ Branch 1 taken 2199 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 154719 times.
156918 if(hp > 0 && !dont_draw())
14981 {
14982 154719 mapscr* scr = get_scr(screen_spawned);
14983
4/4
✓ Branch 0 taken 4731 times.
✓ Branch 1 taken 149988 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 3994 times.
154719 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
14984 737 sprite::drawcloaked(dest);
14985 else
14986 153982 sprite::draw(dest);
14987 154719 }
14988 156918 }
14989
14990
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
1066 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
14991 533 {
14992
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 setParent(prnt);
14993
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 xoffset=0;
14994
2/4
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yoffset=(zfix)((dmisc5*4+2));
14995 // dummy_bool[0]=false;
14996 533 timer=0;
14997 /* fixing */
14998 533 hp=1000;
14999
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 step=1;
15000 533 item_set=0;
15001
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 x = xoffset+parent->x;
15002
4/8
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 533 times.
✗ Branch 7 not taken.
533 y = yoffset+parent->y;
15003 533 hxofs=4;
15004 533 hit_width=8;
15005
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 533 times.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
533 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15006 533 clk2=clk; // how int32_t to wait before moving first time
15007 533 clk=0;
15008 533 mainguy=count_enemy=false;
15009
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dir=zc_oldrand();
15010 533 clk3=((dir&2)>>1)+2; // left or right
15011 533 dir&=1; // up or down
15012
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 dmisc5=vbound(dmisc5,1,255);
15013 533 isCore = false;
15014
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 parentCore = parent->getUID();
15015
2/2
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 533 times.
2665 for(int32_t i=0; i<dmisc5; i++)
15016 {
15017 2132 nxoffset[i] = 0;
15018 2132 nyoffset[i] = 0;
15019
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15020
2/4
✓ Branch 0 taken 2132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15021 2132 }
15022
15023 533 necktile=0;
15024 //TODO compatibility? -DD
15025 /*
15026 for(int32_t i=0; i<4; i++)
15027 {
15028 nx[i]=124;
15029 ny[i]=i*6+48;
15030 }*/
15031 533 bgsfx=-1;
15032 //no need for deadsfx
15033 533 }
15034
15035 515535 bool esGleeok::animate(int32_t index)
15036 {
15037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515535 times.
515535 if(switch_hooked) return enemy::animate(index);
15038 // don't call removearmos() - it's a segment.
15039
15040 515535 dmisc5=vbound(dmisc5,1,255);
15041
15042
2/2
✓ Branch 0 taken 112773 times.
✓ Branch 1 taken 402762 times.
515535 if(misc == 0)
15043 {
15044 402762 x = (xoffset+parent->x);
15045 402762 y = (yoffset+parent->y);
15046
15047
2/2
✓ Branch 0 taken 1611048 times.
✓ Branch 1 taken 402762 times.
2013810 for(int32_t i=0; i<dmisc5; i++)
15048 {
15049 1611048 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15050 1611048 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15051 1611048 }
15052 402762 }
15053
15054 // set up the head tiles
15055 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15056 /*
15057 if (dummy_bool[0]) //if this is a flame gleeok
15058 {
15059 headtile+=180;
15060 }
15061 */
15062 515535 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15063 515535 flyingheadtile=dummy_int[3];
15064
15065 // set up the neck tiles
15066 515535 necktile=dummy_int[1];
15067
15068
2/2
✓ Branch 0 taken 112702 times.
✓ Branch 1 taken 402833 times.
515535 if(get_qr(qr_NEWENEMYTILES))
15069 {
15070 402833 necktile+=((clk&24)>>3);
15071 402833 }
15072
15073 /*
15074 else
15075 {
15076 necktile=145;
15077 }
15078 */
15079 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15080
15081
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 402762 times.
✓ Branch 2 taken 112071 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 402 times.
515535 switch(misc)
15082 {
15083 case 0: // live head
15084 // set up the attached head tiles
15085 402762 tile=headtile;
15086
15087
2/2
✓ Branch 0 taken 82942 times.
✓ Branch 1 taken 319820 times.
402762 if(get_qr(qr_NEWENEMYTILES))
15088 {
15089 319820 tile+=((clk&24)>>3);
15090 /*
15091 if (dummy_bool[0]) {
15092 tile+=1561;
15093 }
15094 */
15095 319820 }
15096
15097 /*
15098 else
15099 {
15100 tile=146;
15101 }
15102 */
15103
4/4
✓ Branch 0 taken 104448 times.
✓ Branch 1 taken 298314 times.
✓ Branch 2 taken 11616 times.
✓ Branch 3 taken 92832 times.
402762 if(++clk2>=0 && !(clk2&3))
15104 {
15105
2/2
✓ Branch 0 taken 90773 times.
✓ Branch 1 taken 2059 times.
92832 if(y<= (int32_t)parent->y + 8) dir=down;
15106
15107
2/2
✓ Branch 0 taken 90911 times.
✓ Branch 1 taken 1921 times.
92832 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15108
15109
4/4
✓ Branch 0 taken 9757 times.
✓ Branch 1 taken 83075 times.
✓ Branch 2 taken 9465 times.
✓ Branch 3 taken 292 times.
92832 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15110 {
15111 292 dir^=1;
15112 292 }
15113
15114 92832 zfix tempx = x;
15115 92832 zfix tempy = y;
15116
15117 92832 sprite::move(step);
15118 92832 xoffset += (x-tempx);
15119 92832 yoffset += (y-tempy);
15120
15121
2/2
✓ Branch 0 taken 3863 times.
✓ Branch 1 taken 88969 times.
92832 if(clk2>=4)
15122 {
15123 3863 clk3^=1;
15124 3863 clk2=-4;
15125 3863 }
15126 else
15127 {
15128
2/2
✓ Branch 0 taken 87991 times.
✓ Branch 1 taken 978 times.
88969 if(x <= (int32_t)parent->x-(dmisc5*6))
15129 {
15130 978 clk3=right;
15131 978 }
15132
15133
2/2
✓ Branch 0 taken 88008 times.
✓ Branch 1 taken 961 times.
88969 if(x >= (int32_t)parent->x+(dmisc5*6))
15134 {
15135 961 clk3=left;
15136 961 }
15137
15138
4/4
✓ Branch 0 taken 60029 times.
✓ Branch 1 taken 28940 times.
✓ Branch 2 taken 56316 times.
✓ Branch 3 taken 3713 times.
88969 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15139 {
15140 3713 clk3^=1; // x jig
15141 3713 }
15142 else
15143 {
15144
4/4
✓ Branch 0 taken 29223 times.
✓ Branch 1 taken 56033 times.
✓ Branch 2 taken 28372 times.
✓ Branch 3 taken 851 times.
85256 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15145 {
15146 851 clk3^=1; // x switch back
15147 851 }
15148
15149 85256 clk2=-4;
15150 }
15151 }
15152
15153 92832 zc_swap(dir,clk3);
15154 92832 tempx = x;
15155 92832 tempy = y;
15156 92832 sprite::move(step);
15157 92832 xoffset += (x-tempx);
15158 92832 yoffset += (y-tempy);
15159 92832 zc_swap(dir,clk3);
15160
15161
2/2
✓ Branch 0 taken 278496 times.
✓ Branch 1 taken 92832 times.
371328 for(int32_t i=1; i<dmisc5; i++)
15162 {
15163 278496 nxoffset[i] = (zc_oldrand()%3);
15164 278496 nyoffset[i] = (zc_oldrand()%3);
15165 278496 }
15166 92832 }
15167
15168 402762 break;
15169
15170 case 1: // flying head
15171
2/2
✓ Branch 0 taken 6589 times.
✓ Branch 1 taken 105482 times.
112071 if(clk>=0)
15172
15173 {
15174 105482 variable_walk_8(rate,homing,hrate,spw_floater);
15175 105482 }
15176
15177 112071 break;
15178
15179 // the following are messages sent from the main guy...
15180 case -1: // got chopped off
15181 {
15182 300 misc=1;
15183 300 superman=1;
15184 300 hxofs=xofs=0;
15185 300 hit_width=16;
15186 300 cs=8;
15187 300 clk=-24;
15188 300 clk2=40;
15189 300 dir=(zc_oldrand()&7)+8;
15190 300 step=8.0/9.0;
15191 }
15192 300 break;
15193
15194 case -2: // the big guy is dead
15195 402 return true;
15196 }
15197
15198
2/2
✓ Branch 0 taken 475008 times.
✓ Branch 1 taken 40125 times.
515133 if(timer)
15199 {
15200
2/2
✓ Branch 0 taken 35334 times.
✓ Branch 1 taken 4791 times.
40125 if(!(timer%8))
15201 {
15202 4791 FireBreath(true);
15203 4791 }
15204
15205 40125 --timer;
15206 40125 }
15207
15208 515133 return enemy::animate(index);
15209 515535 }
15210
15211 7080 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
15212 {
15213
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7080 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7080 if ((editorflags & ENEMY_FLAG7) && misc == 1)
15214 {
15215 int32_t wpnId = w->id;
15216
15217 if(dying)
15218 return 0;
15219
15220 switch(wpnId)
15221 {
15222 case wLitBomb:
15223 case wLitSBomb:
15224 case wBait:
15225 case wWhistle:
15226 case wFire:
15227 case wWind:
15228 case wSSparkle:
15229 case wFSparkle:
15230 case wPhantom:
15231 return 0;
15232
15233 case wHookshot:
15234 case wBrang:
15235 case wBeam:
15236 case wArrow:
15237 case wMagic:
15238 case wBomb:
15239 case wSBomb:
15240 sfx(WAV_CHINK,pan(int32_t(x)));
15241 break;
15242 default:
15243 break;
15244 }
15245
15246 return 1;
15247 }
15248 else
15249 {
15250 7080 int32_t ret = enemy::takehit(w,realweap);
15251
15252
2/2
✓ Branch 0 taken 1425 times.
✓ Branch 1 taken 5655 times.
7080 if(ret==-1)
15253 5655 return -2; // force it to wait a frame before checking sword attacks again
15254
15255 1425 return ret;
15256 }
15257 7080 }
15258
15259 521456 void esGleeok::draw(BITMAP *dest)
15260 {
15261 521456 dmisc5=vbound(dmisc5,1,255);
15262
15263
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 409106 times.
✓ Branch 2 taken 112350 times.
521456 switch(misc)
15264 {
15265 case 0: //neck
15266
1/2
✓ Branch 0 taken 409106 times.
✗ Branch 1 not taken.
409106 if(!dont_draw())
15267 {
15268
2/2
✓ Branch 0 taken 1227318 times.
✓ Branch 1 taken 409106 times.
1636424 for(int32_t i=1; i<dmisc5; i++) //draw the neck
15269 {
15270 1227318 mapscr* scr = get_scr(screen_spawned);
15271
2/2
✓ Branch 0 taken 978198 times.
✓ Branch 1 taken 249120 times.
1227318 if(get_qr(qr_NEWENEMYTILES))
15272 {
15273
4/4
✓ Branch 0 taken 23100 times.
✓ Branch 1 taken 955098 times.
✓ Branch 2 taken 20889 times.
✓ Branch 3 taken 2211 times.
978198 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15274 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15275 else
15276 975987 overtile16(dest,necktile+(i*dmisc7),nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15277 978198 }
15278 else
15279 {
15280
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 244842 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
249120 if((scr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15281 overtilecloaked16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,0);
15282 else
15283 249120 overtile16(dest,necktile,nx[i]-4-viewport.x,ny[i]+playing_field_offset-viewport.y,cs,0);
15284 }
15285 1227318 }
15286 409106 }
15287
15288 409106 break;
15289
15290 case 1: //flying head
15291 112350 tile=flyingheadtile;
15292
15293
2/2
✓ Branch 0 taken 82692 times.
✓ Branch 1 taken 29658 times.
112350 if(get_qr(qr_NEWENEMYTILES))
15294 {
15295 82692 tile+=((clk&24)>>3);
15296 82692 break;
15297 }
15298 29658 }
15299 521456 }
15300
15301 521456 void esGleeok::draw2(BITMAP *dest)
15302 {
15303 521456 enemy::draw(dest);
15304 521456 }
15305
15306 189 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
15307 189 {
15308
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if ( !(editorflags & ENEMY_FLAG5) )
15309 {
15310
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 x = 128;
15311
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 y = 48;
15312 189 }
15313 else { x = X; y = Y; }
15314 189 adjusted=false;
15315
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 dir=(zc_oldrand()&7)+8;
15316 //step=0.25;
15317 189 flycnt=dmisc1;
15318 189 flycnt2=dmisc2;
15319 189 loopcnt=0;
15320 189 clk4 = 0;
15321 189 clk5 = 0;
15322 189 clk6 = 0;
15323 189 clk7 = 0;
15324
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
15325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if (dmisc29 == 0)
15326 {
15327
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 105 times.
189 if(!dmisc4)
15328 {
15329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc29 = (90 / 3);
15330 105 else dmisc29 = (84 / 3);
15331 105 }
15332 else
15333 {
15334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if (dmisc10) dmisc29 = (90 / 2);
15335 84 else dmisc29 = (84 / 2);
15336 }
15337 189 }
15338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if (dmisc30 == 0)
15339 {
15340
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 105 times.
189 if(!dmisc4)
15341 {
15342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc30 = (90 / 3)*0.5;
15343 105 else dmisc30 = (84 / 3)*0.5;
15344 105 }
15345 else
15346 {
15347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if (dmisc10) dmisc30 = (90 / 2)*0.5;
15348 84 else dmisc30 = (84 / 2)*0.5;
15349 }
15350 189 }
15351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if (dmisc31 == 0)
15352 {
15353
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 105 times.
189 if(!dmisc4)
15354 {
15355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc31 = (90 / 3)*2;
15356 105 else dmisc31 = (84 / 3)*2;
15357 105 }
15358 else
15359 {
15360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if (dmisc10) dmisc31 = (90 / 2)*0.5;
15361 84 else dmisc31 = (84 / 2)*0.5;
15362 }
15363 189 }
15364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if (dmisc32 == 0)
15365 {
15366
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 105 times.
189 if(!dmisc4)
15367 {
15368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
105 if (dmisc10) dmisc32 = (90 / 3);
15369 105 else dmisc32 = (84 / 3);
15370 105 }
15371 else
15372 {
15373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if (dmisc10) dmisc32 = (90 / 2)*0.25;
15374 84 else dmisc32 = (84 / 2)*0.25;
15375 }
15376 189 }
15377
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 init_size_flags();
15378 189 }
15379
15380 158531 bool ePatra::animate(int32_t index)
15381 {
15382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 158531 times.
158531 if(switch_hooked) return enemy::animate(index);
15383
2/2
✓ Branch 0 taken 1426 times.
✓ Branch 1 taken 157105 times.
158531 if(dying)
15384 {
15385
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1426 times.
1498 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
15386 {
15387 72 auto segment = (enemy*)guys.spr(i);
15388
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
72 if (segment && segment->parent == this)
15389 72 segment->hp = -1000;
15390 72 }
15391
15392 1426 return Dead(index);
15393 }
15394
15395 157105 double basesize = 84;
15396
1/2
✓ Branch 0 taken 157105 times.
✗ Branch 1 not taken.
157105 if (dmisc10) basesize = 90;
15397 157105 double halfsize = basesize / 2;
15398 157105 double quartersize = halfsize / 2;
15399 157105 double twothirdsize = (basesize / 3)*2;
15400 157105 double onethirdsize = (basesize / 3);
15401
15402
15403
2/2
✓ Branch 0 taken 121002 times.
✓ Branch 1 taken 36103 times.
157105 if(clk==0)
15404 {
15405 36103 removearmos(x,y,ffcactivated);
15406 36103 }
15407
15408
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 157105 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 157105 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
157105 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
15409 {
15410
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 157105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
157105 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
15411
1/2
✓ Branch 0 taken 157105 times.
✗ Branch 1 not taken.
157105 if (loopcnt < 0) ++clk2;
15412
2/2
✓ Branch 0 taken 155347 times.
✓ Branch 1 taken 1758 times.
157105 if(++clk2>basesize)
15413 {
15414 1758 clk2=0;
15415
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 1758 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1758 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1758 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
15416 {
15417
2/2
✓ Branch 0 taken 912 times.
✓ Branch 1 taken 846 times.
1758 if(loopcnt > 0)
15418 912 --loopcnt;
15419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 846 times.
846 else if (loopcnt == 0)
15420 {
15421
2/2
✓ Branch 0 taken 495 times.
✓ Branch 1 taken 351 times.
846 if (zc::math::SafeMod(misc, dmisc6) == 0)
15422 {
15423
1/2
✓ Branch 0 taken 351 times.
✗ Branch 1 not taken.
351 if (dmisc21 > 0) loopcnt=-dmisc21;
15424 351 else loopcnt=dmisc7;
15425 351 }
15426 846 }
15427 else if (loopcnt == -1) loopcnt=dmisc7;
15428 else ++loopcnt;
15429
15430
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1758 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1758 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
15431 1758 }
15432 else
15433 {
15434 loopcnt = 0;
15435 misc = 1;
15436 }
15437 1758 }
15438 157105 }
15439
1/2
✓ Branch 0 taken 157105 times.
✗ Branch 1 not taken.
157105 if (clk4 > 0) --clk4;
15440
15441
1/2
✓ Branch 0 taken 157105 times.
✗ Branch 1 not taken.
157105 if (clk6 < 0)
15442 {
15443 if (dmisc5 == 1 || dmisc5 == 3)
15444 {
15445 if (get_qr(qr_NEWENEMYTILES))
15446 {
15447 if (clk7 <= 0 || clk6 != -16) ++clk6;
15448 if (clk6 == 0) o_tile=d->e_tile;
15449 else
15450 {
15451 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
15452 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
15453 }
15454 }
15455 else clk6 = 0;
15456 }
15457 }
15458
1/2
✓ Branch 0 taken 157105 times.
✗ Branch 1 not taken.
157105 else if (dmisc19) ++clk6;
15459
1/2
✓ Branch 0 taken 157105 times.
✗ Branch 1 not taken.
157105 if (clk5 < 0) ++clk5;
15460
1/2
✓ Branch 0 taken 157105 times.
✗ Branch 1 not taken.
157105 else if (dmisc19) ++clk5;
15461
15462
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 157105 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
157105 if (clk7 > 0 && clk6 >= -16) --clk7;
15463
1/2
✓ Branch 0 taken 157105 times.
✗ Branch 1 not taken.
157105 if (clk6 > 0) clk7 = 0;
15464
15465
2/2
✓ Branch 0 taken 642968 times.
✓ Branch 1 taken 157105 times.
800073 for(int32_t i=index+1; i<index+flycnt+1; i++)
15466 {
15467 //outside ring
15468
2/2
✓ Branch 0 taken 641632 times.
✓ Branch 1 taken 1336 times.
642968 if(!adjusted)
15469 {
15470
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 184 times.
1336 if(get_qr(qr_NEWENEMYTILES))
15471 {
15472 1152 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
15473 1152 enemy *s = ((enemy*)guys.spr(i));
15474 1152 s->setParent(this);
15475 1152 }
15476 else
15477 {
15478 184 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15479 184 enemy *s = ((enemy*)guys.spr(i));
15480 184 s->setParent(this);
15481 }
15482
15483 1336 ((enemy*)guys.spr(i))->cs=dmisc9;
15484 1336 ((enemy*)guys.spr(i))->hp=dmisc3;
15485 1336 }
15486
15487
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 642212 times.
642968 if(((enemy*)guys.spr(i))->hp <= 0)
15488 {
15489
2/2
✓ Branch 0 taken 2875 times.
✓ Branch 1 taken 756 times.
3631 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15490 {
15491 2875 guys.swap(j,j+1);
15492 2875 }
15493
15494
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 663 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
756 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
15495 756 }
15496 else
15497 {
15498 642212 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15499
1/2
✓ Branch 0 taken 642212 times.
✗ Branch 1 not taken.
642212 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
15500
15501
2/2
✓ Branch 0 taken 194629 times.
✓ Branch 1 taken 447583 times.
642212 if(!dmisc4) //Big Ring
15502 {
15503 //maybe playing_field_offset here?
15504
2/2
✓ Branch 0 taken 237330 times.
✓ Branch 1 taken 210253 times.
447583 if(loopcnt>0)
15505 {
15506
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15507
1/2
✓ Branch 0 taken 237330 times.
✗ Branch 1 not taken.
237330 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
15508 237330 }
15509 else
15510 {
15511 210253 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15512 210253 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15513 }
15514
15515 447583 temp_x=guys.spr(i)->x;
15516 447583 temp_y=guys.spr(i)->y;
15517 447583 }
15518 else //Oval
15519 {
15520 194629 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15521 194629 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
15522
15523
2/2
✓ Branch 0 taken 112067 times.
✓ Branch 1 taken 82562 times.
194629 if(loopcnt>0)
15524 {
15525 112067 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
15526
1/2
✓ Branch 0 taken 112067 times.
✗ Branch 1 not taken.
112067 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
15527 112067 }
15528 else
15529 {
15530 82562 guys.spr(i)->x = circle_x;
15531 82562 guys.spr(i)->y = circle_y;
15532 }
15533
15534 194629 temp_x=circle_x;
15535 194629 temp_y=circle_y;
15536 }
15537
15538 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15539 642212 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15540
15541
4/4
✓ Branch 0 taken 120677 times.
✓ Branch 1 taken 521535 times.
✓ Branch 2 taken 39732 times.
✓ Branch 3 taken 80945 times.
642212 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15542 {
15543 80945 guys.spr(i)->dir=l_down;
15544 80945 }
15545
4/4
✓ Branch 0 taken 121129 times.
✓ Branch 1 taken 440138 times.
✓ Branch 2 taken 39732 times.
✓ Branch 3 taken 81397 times.
561267 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15546 {
15547 81397 guys.spr(i)->dir=left;
15548 81397 }
15549
4/4
✓ Branch 0 taken 120033 times.
✓ Branch 1 taken 359837 times.
✓ Branch 2 taken 39732 times.
✓ Branch 3 taken 80301 times.
479870 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15550 {
15551 80301 guys.spr(i)->dir=l_up;
15552 80301 }
15553
4/4
✓ Branch 0 taken 119766 times.
✓ Branch 1 taken 279803 times.
✓ Branch 2 taken 39732 times.
✓ Branch 3 taken 80034 times.
399569 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15554 {
15555 80034 guys.spr(i)->dir=up;
15556 80034 }
15557
4/4
✓ Branch 0 taken 119141 times.
✓ Branch 1 taken 200394 times.
✓ Branch 2 taken 39732 times.
✓ Branch 3 taken 79409 times.
319535 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15558 {
15559 79409 guys.spr(i)->dir=r_up;
15560 79409 }
15561
4/4
✓ Branch 0 taken 119528 times.
✓ Branch 1 taken 120598 times.
✓ Branch 2 taken 39732 times.
✓ Branch 3 taken 79796 times.
240126 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15562 {
15563 79796 guys.spr(i)->dir=right;
15564 79796 }
15565
4/4
✓ Branch 0 taken 119250 times.
✓ Branch 1 taken 41080 times.
✓ Branch 2 taken 39732 times.
✓ Branch 3 taken 79518 times.
160330 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15566 {
15567 79518 guys.spr(i)->dir=r_down;
15568 79518 }
15569 else
15570 {
15571 80812 guys.spr(i)->dir=down;
15572 }
15573
15574 642212 guys.spr(i)->x += x;
15575 642212 guys.spr(i)->y += y;
15576 }
15577 642968 }
15578
15579
7/22
✓ Branch 0 taken 103621 times.
✓ Branch 1 taken 53484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 103621 times.
✓ Branch 4 taken 21153 times.
✓ Branch 5 taken 32331 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 32331 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
157105 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
15580 {
15581 32331 int timeneeded = 48;
15582 32331 int patbreath = (zc_oldrand()%50+50);
15583
2/2
✓ Branch 0 taken 24549 times.
✓ Branch 1 taken 7782 times.
32331 if ((patbreath % 4) == 0) ++patbreath;
15584
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratBREATH)
15585 {
15586 timeneeded = 48 + patbreath;
15587 }
15588
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (dmisc28 == patratSTREAM)
15589 {
15590 timeneeded = 48 + 96;
15591 }
15592
4/14
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32331 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 249 times.
✓ Branch 11 taken 249 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
32331 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
15593
2/2
✓ Branch 0 taken 32331 times.
✓ Branch 1 taken 249 times.
32580 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
15594
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 32082 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
32580 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15595 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
15596 249 && (clk6 >= 0) //if not in the middle of firing...
15597 249 && clk6 >= dmisc19) //if over the set cooldown between shots...
15598
2/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
249 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
15599 {
15600
1/3
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
249 switch(dmisc28)
15601 {
15602 case patratSTREAM:
15603 {
15604 clk7 = 97;
15605 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15606 else clk6 = 0;
15607 break;
15608 }
15609 case patratBREATH:
15610 {
15611 clk7 = patbreath;
15612 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
15613 else clk6 = 0;
15614 break;
15615 }
15616 default:
15617 {
15618
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15619 {
15620 clk6 = -48;
15621 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15622 }
15623 else
15624 {
15625 249 clk6 = 0;
15626
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15627 249 FirePatraWeapon();
15628 }
15629 249 break;
15630 }
15631 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15632 249 }
15633
1/2
✓ Branch 0 taken 32331 times.
✗ Branch 1 not taken.
32331 if (clk6 < 0)
15634 {
15635 switch(dmisc28)
15636 {
15637 case patratSTREAM:
15638 {
15639 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
15640 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15641 break;
15642 }
15643 case patratBREATH:
15644 {
15645 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
15646 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15647 break;
15648 }
15649 default:
15650 {
15651 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
15652 {
15653 FirePatraWeapon();
15654 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
15655 }
15656 break;
15657 }
15658 }
15659 }
15660 32331 }
15661
15662 157105 int randattempts = 0;
15663 157105 int randeye = 0;
15664
2/2
✓ Branch 0 taken 110865 times.
✓ Branch 1 taken 46240 times.
157105 if (flycnt2 > 0)
15665 {
15666 46240 do
15667 {
15668
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✓ Branch 2 taken 44221 times.
✓ Branch 3 taken 2019 times.
46240 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
15669 46240 randeye += (index + flycnt + 1);
15670 46240 ++randattempts;
15671
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46240 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46240 times.
46240 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
15672 46240 }
15673 157105 bool dofire = false;
15674
1/2
✓ Branch 0 taken 157105 times.
✗ Branch 1 not taken.
157105 if (dmisc20)
15675 {
15676 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15677 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
15678 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
15679 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
15680 || (((((zc::math::SafeMod(misc, dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
15681 {
15682 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15683 {
15684 if (clk5 >= dmisc19)
15685 {
15686 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15687 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
15688 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > ((int64_t)48 + 96)) ||
15689 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48)))
15690 || dmisc18 == -1)
15691 dofire = true;
15692 }
15693 }
15694 }
15695 }
15696
2/2
✓ Branch 0 taken 110865 times.
✓ Branch 1 taken 46240 times.
157105 if(flycnt2)
15697 {
15698
2/2
✓ Branch 0 taken 334429 times.
✓ Branch 1 taken 46240 times.
380669 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
15699 {
15700
2/2
✓ Branch 0 taken 334117 times.
✓ Branch 1 taken 312 times.
334429 if(!adjusted)
15701 {
15702 312 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
15703
15704
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if(get_qr(qr_NEWENEMYTILES))
15705 {
15706
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15707 {
15708
2/3
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 168 times.
✗ Branch 2 not taken.
312 switch(dmisc5)
15709 {
15710 // Center eye shoots projectiles; make room for its firing tiles
15711 case 1:
15712 case 3:
15713 144 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
15714 144 break;
15715
15716 // Center eyes does not shoot; use tiles two rows below for inner eyes.
15717 default:
15718 case 2:
15719 168 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
15720 168 break;
15721 }
15722 312 }
15723 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
15724 312 }
15725 else
15726 {
15727 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
15728 }
15729
15730 312 ((enemy*)guys.spr(i))->cs=dmisc9;
15731
1/2
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
312 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
15732 312 }
15733
15734
2/2
✓ Branch 0 taken 263816 times.
✓ Branch 1 taken 70613 times.
334429 if(flycnt>0)
15735 {
15736 263816 ((enemy*)guys.spr(i))->superman=true;
15737 263816 }
15738 else
15739 {
15740 70613 ((enemy*)guys.spr(i))->superman=false;
15741 }
15742
15743
2/2
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 334284 times.
334429 if(((enemy*)guys.spr(i))->hp <= 0)
15744 {
15745
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 145 times.
414 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
15746 {
15747 269 guys.swap(j,j+1);
15748 269 }
15749
15750
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
145 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
15751 145 }
15752 else
15753 {
15754 334284 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
15755
1/2
✓ Branch 0 taken 334284 times.
✗ Branch 1 not taken.
334284 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
15756
15757
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 327025 times.
334284 if(dmisc4==0)
15758 {
15759
2/2
✓ Branch 0 taken 168378 times.
✓ Branch 1 taken 158647 times.
327025 if(loopcnt>0)
15760 {
15761
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15762
1/2
✓ Branch 0 taken 168378 times.
✗ Branch 1 not taken.
168378 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
15763 168378 }
15764 else
15765 {
15766 158647 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15767 158647 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15768 }
15769
15770 327025 temp_x=guys.spr(i)->x;
15771 327025 temp_y=guys.spr(i)->y;
15772 327025 }
15773 else
15774 {
15775 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15776 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
15777
15778
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
15779 {
15780 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
15781
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
15782 3965 }
15783 else
15784 {
15785 3294 guys.spr(i)->x = circle_x;
15786 3294 guys.spr(i)->y = circle_y;
15787 }
15788
15789 7259 temp_x=circle_x;
15790 7259 temp_y=circle_y;
15791 }
15792
15793 double _MSVC2022_tmp1, _MSVC2022_tmp2;
15794 334284 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
15795
15796
4/4
✓ Branch 0 taken 61619 times.
✓ Branch 1 taken 272665 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41746 times.
334284 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
15797 {
15798 41746 guys.spr(i)->dir=l_down;
15799 41746 }
15800
4/4
✓ Branch 0 taken 61607 times.
✓ Branch 1 taken 230931 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41734 times.
292538 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
15801 {
15802 41734 guys.spr(i)->dir=left;
15803 41734 }
15804
4/4
✓ Branch 0 taken 61615 times.
✓ Branch 1 taken 189189 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41742 times.
250804 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
15805 {
15806 41742 guys.spr(i)->dir=l_up;
15807 41742 }
15808
4/4
✓ Branch 0 taken 61631 times.
✓ Branch 1 taken 147431 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41758 times.
209062 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
15809 {
15810 41758 guys.spr(i)->dir=up;
15811 41758 }
15812
4/4
✓ Branch 0 taken 61703 times.
✓ Branch 1 taken 105601 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41830 times.
167304 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
15813 {
15814 41830 guys.spr(i)->dir=r_up;
15815 41830 }
15816
4/4
✓ Branch 0 taken 61697 times.
✓ Branch 1 taken 63777 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41824 times.
125474 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
15817 {
15818 41824 guys.spr(i)->dir=right;
15819 41824 }
15820
4/4
✓ Branch 0 taken 61725 times.
✓ Branch 1 taken 21925 times.
✓ Branch 2 taken 19873 times.
✓ Branch 3 taken 41852 times.
83650 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
15821 {
15822 41852 guys.spr(i)->dir=r_down;
15823 41852 }
15824 else
15825 {
15826 41798 guys.spr(i)->dir=down;
15827 }
15828
15829 334284 guys.spr(i)->x += x;
15830 334284 guys.spr(i)->y = y-guys.spr(i)->y;
15831
15832
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 334284 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 189016 times.
✓ Branch 5 taken 145268 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 189016 times.
334284 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
15833 {
15834 /*
15835 if(!(zc_oldrand()&127))
15836 {
15837 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
15838 sfx(wpnsfx(wpn),pan(int32_t(x)));
15839 }
15840 */
15841
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
145268 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
15842 {
15843 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
15844 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
15845 {
15846 if (dmisc5 == 3)
15847 {
15848 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15849 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
15850 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
15851 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15852 }
15853 else
15854 {
15855 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15856 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
15857 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
15858 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
15859 }
15860 }
15861 else
15862 {
15863 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15864 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
15865 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
15866 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
15867 }
15868 }
15869
4/6
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145268 times.
✓ Branch 4 taken 145268 times.
✓ Branch 5 taken 145268 times.
145268 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
15870
1/2
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
145268 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
15871
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
15872 {
15873
1/5
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
145268 switch(dmisc20) //Patra Attack Patterns
15874 {
15875 case 4: //Single one rapidfires
15876 {
15877 if (dofire && i == randeye)
15878 {
15879 ((esPatra*)guys.spr(i))->clk5 = -16;
15880 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
15881 ((esPatra*)guys.spr(i))->clk4 = 96;
15882 clk5 = -3;
15883 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15884 }
15885 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
15886 {
15887 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15888 sfx(wpnsfx(wpn),pan(int32_t(x)));
15889 }
15890 break;
15891 }
15892 case 3: //Ring
15893 {
15894 if (dofire)
15895 {
15896 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15897 {
15898 ((esPatra*)guys.spr(i))->clk5 = -48;
15899 clk5 = -48;
15900 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15901 }
15902 else
15903 {
15904 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15905 sfx(wpnsfx(wpn),pan(int32_t(x)));
15906 int32_t m=Ewpns.Count()-1;
15907 weapon *ew = (weapon*)(Ewpns.spr(m));
15908
15909 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15910 ((esPatra*)guys.spr(i))->clk5 = 0;
15911 clk5 = 0;
15912 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15913 }
15914 }
15915 if (((esPatra*)guys.spr(i))->clk5 == -16)
15916 {
15917 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15918 sfx(wpnsfx(wpn),pan(int32_t(x)));
15919 int32_t m=Ewpns.Count()-1;
15920 weapon *ew = (weapon*)(Ewpns.spr(m));
15921
15922 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
15923 }
15924 break;
15925 }
15926 case 2: //one after another
15927 {
15928 if (dofire)
15929 {
15930 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
15931 clk5 = -48 - (12*flycnt2);
15932 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
15933 }
15934 if (((esPatra*)guys.spr(i))->clk5 == -16)
15935 {
15936 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15937 sfx(wpnsfx(wpn),pan(int32_t(x)));
15938 }
15939 break;
15940 }
15941 case 1: //random one eye
15942 {
15943 if (dofire && i == randeye)
15944 {
15945 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15946 {
15947 ((esPatra*)guys.spr(i))->clk5 = -48;
15948 clk5 = -48;
15949 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15950 }
15951 else
15952 {
15953 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15954 sfx(wpnsfx(wpn),pan(int32_t(x)));
15955 ((esPatra*)guys.spr(i))->clk5 = 0;
15956 clk5 = 0;
15957 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15958 }
15959 }
15960 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15961 {
15962 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
15963 sfx(wpnsfx(wpn),pan(int32_t(x)));
15964 }
15965 break;
15966 }
15967 default: //old behavior, all eyes can fire any time
15968 {
15969
3/8
✓ Branch 0 taken 145268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1155 times.
✓ Branch 5 taken 1155 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
145268 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
15970
3/6
✓ Branch 0 taken 145268 times.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1155 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
15971
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
15972 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - zc::math::SafeMod(misc, dmisc6))) > 48))))
15973 {
15974
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1155 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1155 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
15975 {
15976 ((esPatra*)guys.spr(i))->clk5 = -48;
15977 if (editorflags & ENEMY_FLAG6) clk4 = 64;
15978 }
15979 else
15980 {
15981 1155 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15982 1155 sfx(wpnsfx(wpn),pan(int32_t(x)));
15983 1155 ((esPatra*)guys.spr(i))->clk5 = 0;
15984
1/2
✓ Branch 0 taken 1155 times.
✗ Branch 1 not taken.
1155 if (editorflags & ENEMY_FLAG6) clk4 = 16;
15985 }
15986 1155 }
15987
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147578 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
15988 {
15989 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
15990 sfx(wpnsfx(wpn),pan(int32_t(x)));
15991 }
15992 145268 break;
15993 }
15994 }
15995 145268 }
15996 145268 }
15997
15998 }
15999 334429 }
16000 46240 }
16001
16002 157105 adjusted=true;
16003 157105 return enemy::animate(index);
16004 158531 }
16005
16006 249 void ePatra::FirePatraWeapon()
16007 { //.707
16008 249 int32_t xoff = 0;
16009 249 int32_t yoff = 0;
16010
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_WIDTH)
16011 {
16012 xoff += hxofs;
16013 if (weap_data.override_flags & OVERRIDE_HIT_WIDTH)
16014 xoff += (hit_width / 2) - (weap_data.tilew * 8);
16015 else
16016 xoff += (hit_width / 2) - 8;
16017 }
16018
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (SIZEflags & OVERRIDE_HIT_HEIGHT)
16019 {
16020 yoff += hyofs;
16021 if (weap_data.override_flags & OVERRIDE_HIT_HEIGHT)
16022 yoff += (hit_height / 2) - (weap_data.tileh * 8);
16023 else
16024 yoff += (hit_height / 2) - 8;
16025 }
16026 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16027 // TODO(crash): check that .add succeeds.
16028
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
249 switch (dmisc28)
16029 {
16030 case patrat8SHOT: //Fire Wizzrobe
16031 case patrat4SHOTDIAG:
16032 case patrat4SHOTRAND:
16033 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16034 {
16035 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16036 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16037 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16038 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16039
16040 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16041 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16042 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16043 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16044
16045 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16046 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16047 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16048 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16049
16050 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16051 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16052 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16053 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16054
16055 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16056 }
16057
16058 [[fallthrough]];
16059 case patrat4SHOTCARD: //Stalfos 3
16060 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16061 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16062 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16063 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16064 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16065 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16066 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16067 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16068 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16069 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16070 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16071 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~move_can_pitfall; //No falling in pits
16072 break;
16073
16074 default:
16075 249 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16076
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16077 249 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16078
3/6
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 249 times.
249 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16079
4/8
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 249 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 249 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 249 times.
249 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16080 {
16081 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16082 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16083 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16084 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16085 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16086 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16087 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16088 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16089 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16090 {
16091 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16092 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16093 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16094 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16095 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16096 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16097 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16098 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16099 }
16100 }
16101 249 break;
16102
16103 }
16104 249 sfx(wpnsfx(wpn),pan(int32_t(x)));
16105 //+0.46364761
16106 //11.80
16107 249 }
16108
16109 317534 void ePatra::draw(BITMAP *dest)
16110 {
16111 317534 tile=o_tile;
16112 317534 update_enemy_frame();
16113 317534 enemy::draw(dest);
16114 317534 }
16115
16116 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16117 {
16118 int32_t ret = enemy::defend(wpnId, power, edef);
16119
16120 if(ret < 0 && (flycnt||flycnt2))
16121 return 0;
16122
16123 return ret;
16124 }
16125
16126 1704 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16127 {
16128 1704 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16129
16130
6/6
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 816 times.
✓ Branch 4 taken 447 times.
✓ Branch 5 taken 321 times.
1704 if(ret < 0 && (flycnt||flycnt2))
16131 1263 return 0;
16132
16133 441 return ret;
16134 1704 }
16135
16136 189 void ePatra::init_size_flags() {
16137 189 SIZEflags = d->SIZEflags;
16138
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
189 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16139
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16140 // al_trace("Enemy txsz:%i\n", txsz);
16141
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
189 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = tysz; if (tysz > 1) extend = 3; }
16142
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = hit_width;
16144
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) hit_width = 32;
16145
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = hit_height;
16146
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = hzsz;
16147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = hxofs;
16148
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) hxofs = -8;
16149
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = hyofs;
16150 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16151
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)xofs;
16152
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if (dmisc10 == 1) xofs = -8;
16153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16154 {
16155 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16156 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16157 }
16158
1/4
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
189 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset) - 8;
16159
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if (editorflags & ENEMY_FLAG8) misc = 1;
16160
16161
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)zofs;
16162
16163 189 }
16164
16165 1648 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16166 1648 {
16167 //cs=8;
16168
1/2
✓ Branch 0 taken 1648 times.
✗ Branch 1 not taken.
1648 setParent(prnt);
16169 1648 item_set=0;
16170 1648 misc=clk;
16171 1648 clk4 = 0;
16172 1648 clk5 = 0;
16173 1648 clk = -((misc*21)>>1)-1;
16174
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1648 times.
✓ Branch 2 taken 1648 times.
✗ Branch 3 not taken.
1648 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16175 1648 hit_width=12;
16176 1648 hit_height=12;
16177 1648 hxofs=2;
16178 1648 hyofs=2;
16179 1648 extend = 0;
16180 1648 txsz = 1;
16181 1648 tysz = 1;
16182 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16183 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16184 int32_t prntSIZEflags = prntenemy->SIZEflags;
16185 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16186 // al_trace("Enemy txsz:%i\n", txsz);
16187 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16188 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16189 else
16190 hxsz=12;
16191 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16192 else
16193 hysz=12;
16194 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16195 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16196 else
16197 hxofs=2;
16198 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16199 else hyofs=2;
16200 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16201 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16202 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16203 {
16204 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16205 }
16206
16207 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16208 */
16209 1648 mainguy=count_enemy=false;
16210 1648 bgsfx=-1;
16211 //o_tile=0;
16212
2/4
✓ Branch 0 taken 1648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1648 times.
✗ Branch 3 not taken.
1648 flags &= (~guy_never_return);
16213 1648 deadsfx = WAV_EDEAD;
16214 1648 hitsfx = WAV_EHIT;
16215 1648 isCore = false;
16216 1648 }
16217
16218 993018 bool esPatra::animate(int32_t index)
16219 {
16220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993018 times.
993018 if(switch_hooked) return enemy::animate(index);
16221
2/2
✓ Branch 0 taken 15016 times.
✓ Branch 1 taken 978002 times.
993018 if(dying)
16222 15016 return Dead(index);
16223
16224 978002 return enemy::animate(index);
16225 993018 }
16226
16227 1993064 void esPatra::draw(BITMAP *dest)
16228 {
16229
2/2
✓ Branch 0 taken 1721294 times.
✓ Branch 1 taken 271770 times.
1993064 if(get_qr(qr_NEWENEMYTILES))
16230 {
16231 1721294 tile = o_tile+(clk&3);
16232
16233
8/9
✓ Branch 0 taken 214278 times.
✓ Branch 1 taken 217924 times.
✓ Branch 2 taken 215346 times.
✓ Branch 3 taken 215726 times.
✓ Branch 4 taken 213062 times.
✓ Branch 5 taken 214350 times.
✓ Branch 6 taken 215734 times.
✓ Branch 7 taken 214874 times.
✗ Branch 8 not taken.
1721294 switch(dir) //directions get screwed up after 8. *shrug*
16234 {
16235 case up: //u
16236 214278 flip=0;
16237 214278 break;
16238
16239 case down: //d
16240 217924 flip=0;
16241 217924 tile+=4;
16242 217924 break;
16243
16244 case left: //l
16245 215346 flip=0;
16246 215346 tile+=8;
16247 215346 break;
16248
16249 case right: //r
16250 215726 flip=0;
16251 215726 tile+=12;
16252 215726 break;
16253
16254 case l_up: //ul
16255 213062 flip=0;
16256 213062 tile+=20;
16257 213062 break;
16258
16259 case r_up: //ur
16260 214350 flip=0;
16261 214350 tile+=24;
16262 214350 break;
16263
16264 case l_down: //dl
16265 215734 flip=0;
16266 215734 tile+=28;
16267 215734 break;
16268
16269 case r_down: //dr
16270 214874 flip=0;
16271 214874 tile+=32;
16272 214874 break;
16273 }
16274 1721294 }
16275 else
16276 {
16277 271770 tile = o_tile+((clk&2)>>1);
16278 }
16279
16280
2/2
✓ Branch 0 taken 114256 times.
✓ Branch 1 taken 1878808 times.
1993064 if(clk>=0)
16281 1878808 enemy::draw(dest);
16282 1993064 }
16283
16284
16285 102 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
16286 102 {
16287 102 adjusted=false;
16288
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 dir=(zc_oldrand()&7)+8;
16289
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 step=0.25;
16290 102 clk4 = 0;
16291 102 clk5 = 0;
16292 //flycnt=6; flycnt2=0;
16293 102 flycnt=dmisc1;
16294 102 flycnt2=0; // PatraBS doesn't have inner rings!
16295 102 loopcnt=0;
16296
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_size_flags();
16297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16298
16299 //nets+4480;
16300 102 }
16301
16302 35963 bool ePatraBS::animate(int32_t index)
16303 {
16304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35963 times.
35963 if(switch_hooked) return enemy::animate(index);
16305
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 35723 times.
35963 if(dying)
16306 240 return Dead(index);
16307
16308
2/2
✓ Branch 0 taken 31705 times.
✓ Branch 1 taken 4018 times.
35723 if(clk==0)
16309 {
16310 4018 removearmos(x,y,ffcactivated);
16311 4018 }
16312
16313 35723 variable_walk_8(rate,homing,hrate,spw_floater);
16314
16315
2/2
✓ Branch 0 taken 35387 times.
✓ Branch 1 taken 336 times.
35723 if(++clk2>90)
16316 {
16317 336 clk2=0;
16318
16319
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 159 times.
336 if(loopcnt)
16320 177 --loopcnt;
16321 else
16322 {
16323
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 75 times.
159 if(zc::math::SafeMod(misc, dmisc6)==0)
16324 84 loopcnt=dmisc7;
16325 }
16326
16327 336 ++misc;
16328 336 }
16329
16330 // double size=1;;
16331
2/2
✓ Branch 0 taken 153472 times.
✓ Branch 1 taken 35723 times.
189195 for(int32_t i=index+1; i<index+flycnt+1; i++)
16332 {
16333
2/2
✓ Branch 0 taken 152860 times.
✓ Branch 1 taken 612 times.
153472 if(!adjusted)
16334 {
16335 612 ((enemy*)guys.spr(i))->hp=dmisc3;
16336
16337
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(get_qr(qr_NEWENEMYTILES))
16338 {
16339 612 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
16340 612 }
16341 else
16342 {
16343 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16344 }
16345
16346 612 ((enemy*)guys.spr(i))->cs = dmisc9;
16347 612 }
16348
16349
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 153368 times.
153472 if(((enemy*)guys.spr(i))->hp <= 0)
16350 {
16351
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 104 times.
235 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16352 {
16353 131 guys.swap(j,j+1);
16354 131 }
16355
16356 104 --flycnt;
16357 104 }
16358 else
16359 {
16360 153368 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16361
1/2
✓ Branch 0 taken 153368 times.
✗ Branch 1 not taken.
153368 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
16362 153368 temp_x = zc::math::Cos(a2+PI/2)*45;
16363 153368 temp_y = -zc::math::Sin(a2+PI/2)*45;
16364
16365
2/2
✓ Branch 0 taken 77643 times.
✓ Branch 1 taken 75725 times.
153368 if(loopcnt>0)
16366 {
16367 77643 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
16368
1/2
✓ Branch 0 taken 77643 times.
✗ Branch 1 not taken.
77643 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
16369 77643 }
16370 else
16371 {
16372 75725 guys.spr(i)->x = temp_x;
16373 75725 guys.spr(i)->y = temp_y;
16374 }
16375
16376 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16377 153368 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16378
16379
4/4
✓ Branch 0 taken 29178 times.
✓ Branch 1 taken 124190 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18812 times.
153368 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16380 {
16381 18812 guys.spr(i)->dir=l_down;
16382 18812 }
16383
4/4
✓ Branch 0 taken 29205 times.
✓ Branch 1 taken 105351 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18839 times.
134556 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16384 {
16385 18839 guys.spr(i)->dir=left;
16386 18839 }
16387
4/4
✓ Branch 0 taken 29168 times.
✓ Branch 1 taken 86549 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18802 times.
115717 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16388 {
16389 18802 guys.spr(i)->dir=l_up;
16390 18802 }
16391
4/4
✓ Branch 0 taken 30509 times.
✓ Branch 1 taken 66406 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 20143 times.
96915 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16392 {
16393 20143 guys.spr(i)->dir=up;
16394 20143 }
16395
4/4
✓ Branch 0 taken 28883 times.
✓ Branch 1 taken 47889 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18517 times.
76772 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16396 {
16397 18517 guys.spr(i)->dir=r_up;
16398 18517 }
16399
4/4
✓ Branch 0 taken 29145 times.
✓ Branch 1 taken 29110 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18779 times.
58255 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16400 {
16401 18779 guys.spr(i)->dir=right;
16402 18779 }
16403
4/4
✓ Branch 0 taken 29358 times.
✓ Branch 1 taken 10118 times.
✓ Branch 2 taken 10366 times.
✓ Branch 3 taken 18992 times.
39476 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16404 {
16405 18992 guys.spr(i)->dir=r_down;
16406 18992 }
16407 else
16408 {
16409 20484 guys.spr(i)->dir=down;
16410 }
16411
16412 153368 guys.spr(i)->x += x;
16413 153368 guys.spr(i)->y += y;
16414 }
16415 153472 }
16416
16417 35723 adjusted=true;
16418 35723 return enemy::animate(index);
16419 35963 }
16420
16421 72874 void ePatraBS::draw(BITMAP *dest)
16422 {
16423 72874 tile=o_tile;
16424
16425
1/2
✓ Branch 0 taken 72874 times.
✗ Branch 1 not taken.
72874 if(get_qr(qr_NEWENEMYTILES))
16426 {
16427 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16428 72874 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
16429
16430
4/4
✓ Branch 0 taken 27164 times.
✓ Branch 1 taken 45710 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 19146 times.
72874 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16431 {
16432 19146 lookat=l_down;
16433 19146 }
16434
4/4
✓ Branch 0 taken 26316 times.
✓ Branch 1 taken 27412 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 18298 times.
53728 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16435 {
16436 18298 lookat=down;
16437 18298 }
16438
4/4
✓ Branch 0 taken 21642 times.
✓ Branch 1 taken 13788 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 13624 times.
35430 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16439 {
16440 13624 lookat=r_down;
16441 13624 }
16442
4/4
✓ Branch 0 taken 15510 times.
✓ Branch 1 taken 6296 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 7492 times.
21806 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16443 {
16444 7492 lookat=right;
16445 7492 }
16446
4/4
✓ Branch 0 taken 9188 times.
✓ Branch 1 taken 5126 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 1170 times.
14314 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16447 {
16448 1170 lookat=r_up;
16449 1170 }
16450
4/4
✓ Branch 0 taken 8982 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 8018 times.
✓ Branch 3 taken 964 times.
13144 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16451 {
16452 964 lookat=up;
16453 964 }
16454
4/4
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 2462 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 8018 times.
12180 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16455 {
16456 1700 lookat=l_up;
16457 1700 }
16458 else
16459 {
16460 10480 lookat=left;
16461 }
16462
16463
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 18298 times.
✓ Branch 3 taken 10480 times.
✓ Branch 4 taken 7492 times.
✓ Branch 5 taken 1700 times.
✓ Branch 6 taken 1170 times.
✓ Branch 7 taken 19146 times.
✓ Branch 8 taken 13624 times.
72874 switch(lookat) //directions get screwed up after 8. *shrug*
16464 {
16465 case up: //u
16466 964 flip=0;
16467 964 break;
16468
16469 case down: //d
16470 18298 flip=0;
16471 18298 tile+=8;
16472 18298 break;
16473
16474 case left: //l
16475 10480 flip=0;
16476 10480 tile+=40;
16477 10480 break;
16478
16479 case right: //r
16480 7492 flip=0;
16481 7492 tile+=48;
16482 7492 break;
16483
16484 case l_up: //ul
16485 1700 flip=0;
16486 1700 tile+=80;
16487 1700 break;
16488
16489 case r_up: //ur
16490 1170 flip=0;
16491 1170 tile+=88;
16492 1170 break;
16493
16494 case l_down: //dl
16495 19146 flip=0;
16496 19146 tile+=120;
16497 19146 break;
16498
16499 case r_down: //dr
16500 13624 flip=0;
16501 13624 tile+=128;
16502 13624 break;
16503 }
16504
16505 72874 tile+=(2*(clk&3));
16506 72874 xofs-=8;
16507 72874 yofs-=8;
16508 72874 drawblock(dest,15);
16509 72874 xofs+=8;
16510 72874 yofs+=8;
16511 72874 }
16512 else
16513 {
16514 flip=(clk&1);
16515 xofs-=8;
16516 yofs-=8;
16517 enemy::draw(dest);
16518 xofs+=16;
16519 enemy::draw(dest);
16520 yofs+=16;
16521 enemy::draw(dest);
16522 xofs-=16;
16523 enemy::draw(dest);
16524 xofs+=8;
16525 yofs-=8;
16526 }
16527 72874 }
16528
16529 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
16530 {
16531 int32_t ret = enemy::defend(wpnId, power, edef);
16532
16533 if(ret < 0 && (flycnt||flycnt2))
16534 return 0;
16535
16536 return ret;
16537 }
16538
16539 142 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16540 {
16541 142 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16542
16543
5/6
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60 times.
142 if(ret < 0 && (flycnt||flycnt2))
16544 81 return 0;
16545
16546 61 return ret;
16547 142 }
16548
16549 102 void ePatraBS::init_size_flags()
16550 {
16551 102 SIZEflags = d->SIZEflags;
16552
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_WIDTH) != 0) && txsz > 0) { txsz = d->txsz; if (txsz > 1) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16553 // al_trace("Enemy txsz:%i\n", txsz);
16554
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if (((SIZEflags & OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0) { tysz = d->tysz; if (tysz > 1) extend = 3; }
16555
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0) hit_width = d->hxsz;
16556 102 else hit_width = 32;
16557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0) hit_height = d->hysz;
16558
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if (((SIZEflags & OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0) hzsz = d->hzsz;
16559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if ((SIZEflags & OVERRIDE_HIT_X_OFFSET) != 0) hxofs = d->hxofs;
16560 102 else hxofs = -8;
16561
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_HIT_Y_OFFSET) != 0) hyofs = d->hyofs;
16562 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16563
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_X_OFFSET) != 0) xofs = (int32_t)d->xofs;
16564
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Y_OFFSET) != 0)
16565 {
16566 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16567 yofs += (get_qr(qr_OLD_DRAWOFFSET) ? playing_field_offset : original_playing_field_offset); //this offset fixes yofs not plaing properly. -Z
16568 }
16569
16570
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if ((SIZEflags & OVERRIDE_DRAW_Z_OFFSET) != 0) zofs = (int32_t)d->zofs;
16571 102 }
16572
16573 612 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk)
16574 612 {
16575 //cs=csBOSS;
16576
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 setParent(prnt);
16577 612 item_set=0;
16578 612 misc=clk;
16579 612 clk = -((misc*21)>>1)-1;
16580 612 clk4 = 0;
16581 612 clk5 = 0;
16582
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16583 612 int32_t prntSIZEflags = prntenemy->SIZEflags;
16584
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16585 // al_trace("Enemy txsz:%i\n", txsz);
16586
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16587
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
16588 612 else hit_width=16;
16589
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
16590 612 else hit_height=16;
16591
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
612 if ( ((prntSIZEflags&OVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16592
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if ( (prntSIZEflags&OVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16594 612 else hyofs=2;
16595 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16596
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Y_OFFSET) != 0 )
16598 {
16599 yofs = (int32_t)prntenemy->yofs;
16600 }
16601
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16602
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
612 if ( (prntSIZEflags&OVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
16603
16604 612 bgsfx=-1;
16605 612 mainguy=count_enemy=false;
16606 612 deadsfx = WAV_EDEAD;
16607 612 hitsfx = WAV_EHIT;
16608
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
612 flags &= ~guy_never_return;
16609 612 isCore = false;
16610 612 }
16611
16612 155090 bool esPatraBS::animate(int32_t index)
16613 {
16614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 155090 times.
155090 if(switch_hooked) return enemy::animate(index);
16615
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 153538 times.
155090 if(dying)
16616 1552 return Dead(index);
16617
16618 153538 return enemy::animate(index);
16619 155090 }
16620
16621 315868 void esPatraBS::draw(BITMAP *dest)
16622 {
16623 315868 tile=o_tile;
16624
16625
1/2
✓ Branch 0 taken 315868 times.
✗ Branch 1 not taken.
315868 if(get_qr(qr_NEWENEMYTILES))
16626 {
16627
8/9
✓ Branch 0 taken 41612 times.
✓ Branch 1 taken 42622 times.
✓ Branch 2 taken 37916 times.
✓ Branch 3 taken 38458 times.
✓ Branch 4 taken 38564 times.
✓ Branch 5 taken 38568 times.
✓ Branch 6 taken 38662 times.
✓ Branch 7 taken 39466 times.
✗ Branch 8 not taken.
315868 switch(dir) //directions get screwed up after 8. *shrug*
16628 {
16629 case up: //u
16630 41612 flip=0;
16631 41612 break;
16632
16633 case down: //d
16634 42622 flip=0;
16635 42622 tile+=4;
16636 42622 break;
16637
16638 case left: //l
16639 37916 flip=0;
16640 37916 tile+=8;
16641 37916 break;
16642
16643 case right: //r
16644 38458 flip=0;
16645 38458 tile+=12;
16646 38458 break;
16647
16648 case l_up: //ul
16649 38564 flip=0;
16650 38564 tile+=20;
16651 38564 break;
16652
16653 case r_up: //ur
16654 38568 flip=0;
16655 38568 tile+=24;
16656 38568 break;
16657
16658 case l_down: //dl
16659 38662 flip=0;
16660 38662 tile+=28;
16661 38662 break;
16662
16663 case r_down: //dr
16664 39466 flip=0;
16665 39466 tile+=32;
16666 39466 break;
16667 }
16668
16669 315868 tile += ((clk&6)>>1);
16670 315868 }
16671 else
16672 {
16673 tile += (clk&4)?1:0;
16674 }
16675
16676
2/2
✓ Branch 0 taken 32116 times.
✓ Branch 1 taken 283752 times.
315868 if(clk>=0)
16677 283752 enemy::draw(dest);
16678 315868 }
16679
16680 257606 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
16681 {
16682
4/6
✓ Branch 0 taken 150748 times.
✓ Branch 1 taken 106858 times.
✓ Branch 2 taken 150748 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150748 times.
✗ Branch 5 not taken.
257606 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
16683
4/8
✓ Branch 0 taken 257606 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 257606 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257606 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257606 times.
✗ Branch 7 not taken.
257606 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
16684
1/2
✓ Branch 0 taken 257606 times.
✗ Branch 1 not taken.
257606 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16685 257606 }
16686
16687 74573 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
16688 {
16689 // Kludge
16690
4/8
✓ Branch 0 taken 74573 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74573 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74573 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74573 times.
✗ Branch 7 not taken.
74573 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
16691 74573 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
16692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74573 times.
74573 delete w;
16693 74573 return ret;
16694 }
16695
16696 9202 void enemy_scored(int32_t index)
16697 {
16698 9202 ((enemy*)guys.spr(index))->scored=true;
16699 9202 }
16700
16701 2185 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
16702 {
16703
5/8
✓ Branch 0 taken 2185 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2185 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 279 times.
✓ Branch 5 taken 1906 times.
✓ Branch 6 taken 2185 times.
✗ Branch 7 not taken.
2185 guy *g = new guy((zfix)x,(zfix)y,id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
16704
2/2
✓ Branch 0 taken 1420 times.
✓ Branch 1 taken 765 times.
2185 if (isdungeon(g->screen_spawned))
16705 765 g->y += 1;
16706
5/6
✓ Branch 0 taken 1275 times.
✓ Branch 1 taken 910 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1271 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
2185 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
16707 {
16708 4 g->o_tile = parentscr->guytile;
16709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(g->o_tile != 0)
16710 4 g->flags &= ~guy_invisible;
16711 4 g->cs = parentscr->guycs;
16712 4 }
16713 2185 guys.add(g);
16714 2185 }
16715
16716 23699 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16717 {
16718
4/8
✓ Branch 0 taken 23699 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23699 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23699 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23699 times.
✗ Branch 7 not taken.
23699 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
16719 23699 items.add(i);
16720 23699 }
16721
16722 150 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
16723 {
16724
5/10
✓ Branch 0 taken 150 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 150 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 150 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 150 times.
✗ Branch 9 not taken.
150 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
16725 150 items.add(i);
16726 150 }
16727
16728 3 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
16729 {
16730
5/10
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
3 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
16731 3 items.add(i);
16732 3 }
16733
16734 19302 void add_item_for_screen(int32_t screen, item* item)
16735 {
16736 19302 item->screen_spawned = screen;
16737 19302 items.add(item);
16738 19302 }
16739
16740 96 void kill_em_all()
16741 {
16742
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 96 times.
449 for(int32_t i=0; i<guys.Count(); i++)
16743 {
16744 353 enemy *e = ((enemy*)guys.spr(i));
16745
16746
3/6
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
353 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
16747
16748 323 e->kickbucket();
16749 323 }
16750 96 }
16751
16752 bool can_kill_em_all()
16753 {
16754 for(int32_t i=0; i<guys.Count(); i++)
16755 {
16756 enemy *e = ((enemy*)guys.spr(i));
16757
16758 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
16759 if(e->superman) continue;
16760 return true;
16761 }
16762 return false;
16763 }
16764
16765 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
16766 // For Hero's hit detection. Don't count them if they are stunned or are guys.
16767 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16768 {
16769 for(int32_t i=0; i<guys.Count(); i++)
16770 {
16771 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16772 {
16773 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
16774 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
16775 {
16776 return i;
16777 }
16778 }
16779 }
16780
16781 return -1;
16782 }
16783
16784 13137432 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16785 {
16786
4/4
✓ Branch 0 taken 16511 times.
✓ Branch 1 taken 13120921 times.
✓ Branch 2 taken 33669054 times.
✓ Branch 3 taken 13106465 times.
46775519 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
16787 {
16788
2/2
✓ Branch 0 taken 30967 times.
✓ Branch 1 taken 33638087 times.
33669054 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
16789 {
16790 30967 return i;
16791 }
16792 33638087 }
16793
16794 13106465 return -1;
16795 13137432 }
16796
16797 // For Hero's hit detection. Count them if they are dying.
16798 52420 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
16799 {
16800 52420 enemy *e = (enemy*)guys.spr(index);
16801
3/4
✓ Branch 0 taken 52420 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27987 times.
✓ Branch 3 taken 24433 times.
52420 if(!e || e->hp > 0)
16802 27987 return -1;
16803
16804 24433 bool d = e->dying;
16805 24433 int32_t hc = e->hclk;
16806 24433 e->dying = false;
16807 24433 e->hclk = 0;
16808 24433 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
16809 24433 e->dying = d;
16810 24433 e->hclk = hc;
16811
16812
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 24276 times.
24433 return hit ? index : -1;
16813 52420 }
16814
16815 14653625 bool hasMainGuy(int screen)
16816 {
16817
2/2
✓ Branch 0 taken 15906053 times.
✓ Branch 1 taken 5948223 times.
21854276 for(int32_t i=0; i<guys.Count(); i++)
16818 {
16819 15906053 enemy* e = (enemy*)guys.spr(i);
16820
4/4
✓ Branch 0 taken 15442219 times.
✓ Branch 1 taken 463834 times.
✓ Branch 2 taken 8705402 times.
✓ Branch 3 taken 6736817 times.
15906053 if (e->screen_spawned == screen && e->mainguy)
16821 {
16822 8705402 return true;
16823 }
16824 7200651 }
16825
16826 5948223 return false;
16827 14653625 }
16828
16829 137 void EatHero(int32_t index)
16830 {
16831 137 ((eStalfos*)guys.spr(index))->eathero();
16832 137 }
16833
16834 8 void GrabHero(int32_t index)
16835 {
16836 8 ((eWallM*)guys.spr(index))->grabhero();
16837 8 }
16838
16839 1135 bool CarryHero()
16840 {
16841
1/2
✓ Branch 0 taken 2309 times.
✗ Branch 1 not taken.
2309 for(int32_t i=0; i<guys.Count(); i++)
16842 {
16843
2/2
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 1437 times.
2309 if(((guy*)(guys.spr(i)))->family==eeWALLM)
16844 {
16845
2/2
✓ Branch 0 taken 1135 times.
✓ Branch 1 taken 302 times.
1437 if(((eWallM*)guys.spr(i))->hashero)
16846 {
16847 1135 Hero.x=guys.spr(i)->x;
16848 1135 Hero.y=guys.spr(i)->y;
16849 1135 return ((eWallM*)guys.spr(i))->misc > 0;
16850 }
16851 302 }
16852
16853 // Like Likes currently can't carry Hero.
16854 /*
16855 if(((guy*)(guys.spr(i)))->family==eeLIKE)
16856 {
16857 if(((eLikeLike*)guys.spr(i))->hashero)
16858 {
16859 Hero.x=guys.spr(i)->x;
16860 Hero.y=guys.spr(i)->y;
16861 return (true);
16862 }
16863 }*/
16864 1174 }
16865
16866 return false;
16867 1135 }
16868
16869 // Move item with guy
16870 void movefairy(zfix &x,zfix &y,int32_t misc)
16871 {
16872 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16873
16874 if(i!=-1)
16875 {
16876 x = guys.spr(i)->x;
16877 y = guys.spr(i)->y;
16878 }
16879 }
16880
16881 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16882 void movefairy2(zfix x,zfix y,int32_t misc)
16883 {
16884 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16885
16886 if(i!=-1)
16887 {
16888 guys.spr(i)->x = x;
16889 guys.spr(i)->y = y;
16890 }
16891 }// Move item with guy
16892
16893 60733 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
16894 {
16895 60733 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16896
16897
1/2
✓ Branch 0 taken 60733 times.
✗ Branch 1 not taken.
60733 if(fairy)
16898 {
16899 60733 x = fairy->x;
16900 60733 y = fairy->y;
16901 60733 }
16902 60733 }
16903
16904 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
16905 404 void movefairynew2(zfix x,zfix y, item const &itemfairy)
16906 {
16907 404 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16908
16909
1/2
✓ Branch 0 taken 404 times.
✗ Branch 1 not taken.
404 if(fairy)
16910 {
16911 404 fairy->x = x;
16912 404 fairy->y = y;
16913 404 }
16914 404 }
16915
16916 void killfairy(int32_t misc)
16917 {
16918 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
16919 guys.del(i);
16920 }
16921
16922 218 int32_t getGuyIndex(const int32_t eid)
16923 {
16924
1/2
✓ Branch 0 taken 826 times.
✗ Branch 1 not taken.
826 for(word i = 0; i < guys.Count(); i++)
16925 {
16926
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 608 times.
826 if(guys.spr(i)->getUID() == eid)
16927 218 return i;
16928 608 }
16929
16930 return -1;
16931 218 }
16932
16933 218 void killfairynew(item const &itemfairy)
16934 {
16935 218 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
16936
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
16937 218 }
16938
16939 //Should probably change this to return an 'enemy*', null on failure -Em
16940 21796 int32_t addenemy(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk)
16941 {
16942 21796 return addenemy_z(screen,x,y,0,id,clk);
16943 }
16944
16945 1965 int32_t addchild(int32_t screen, int32_t x,int32_t y,int32_t id,int32_t clk, sprite* parent)
16946 {
16947 1965 return addchild_z(screen,x,y,0,id,clk, parent);
16948 }
16949
16950 1997 int32_t addchild_z(int32_t screen, int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, sprite* parent)
16951 {
16952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1997 times.
1997 if(id <= 0) return 0;
16953
16954 1997 int32_t ret = 0;
16955 1997 sprite *e=NULL;
16956
16957
6/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 110 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1865 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
1997 switch(guysbuf[id&0xFFF].family)
16958 {
16959 //Fixme: possible enemy memory leak. (minor)
16960 case eeWALK:
16961
3/6
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 110 times.
✗ Branch 5 not taken.
110 e = new eStalfos((zfix)x,(zfix)y,id,clk);
16962 110 break;
16963
16964 case eeLEV:
16965 e = new eLeever((zfix)x,(zfix)y,id,clk);
16966 break;
16967
16968 case eeTEK:
16969 e = new eTektite((zfix)x,(zfix)y,id,clk);
16970 break;
16971
16972 case eePEAHAT:
16973 e = new ePeahat((zfix)x,(zfix)y,id,clk);
16974 break;
16975
16976 case eeZORA:
16977 e = new eZora((zfix)x,(zfix)y,id,clk);
16978 break;
16979
16980 case eeGHINI:
16981 e = new eGhini((zfix)x,(zfix)y,id,clk);
16982 break;
16983
16984 case eeKEESE:
16985
3/6
✓ Branch 0 taken 1865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1865 times.
✗ Branch 5 not taken.
1865 e = new eKeese((zfix)x,(zfix)y,id,clk);
16986 1865 break;
16987
16988 case eeWIZZ:
16989
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
16990 15 break;
16991
16992 case eePROJECTILE:
16993 e = new eProjectile((zfix)x,(zfix)y,id,clk);
16994 break;
16995
16996 case eeWALLM:
16997 e = new eWallM((zfix)x,(zfix)y,id,clk);
16998 break;
16999
17000 case eeAQUA:
17001 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17002 break;
17003
17004 case eeMOLD:
17005 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17006 break;
17007
17008 case eeMANHAN:
17009
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17010 1 break;
17011
17012 case eeGLEEOK:
17013 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17014 break;
17015
17016 case eeGHOMA:
17017 e = new eGohma((zfix)x,(zfix)y,id,clk);
17018 break;
17019
17020 case eeLANM:
17021 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17022 break;
17023
17024 case eeGANON:
17025 e = new eGanon((zfix)x,(zfix)y,id,clk);
17026 break;
17027
17028 case eeFAIRY:
17029 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17030 break;
17031
17032 case eeFIRE:
17033
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eFire((zfix)x,(zfix)y,id,clk);
17034 2 break;
17035
17036 case eeOTHER:
17037 e = new eOther((zfix)x,(zfix)y,id,clk);
17038 break;
17039
17040
17041 case eeSCRIPT01:
17042 case eeSCRIPT02:
17043 case eeSCRIPT03:
17044 case eeSCRIPT04:
17045 case eeSCRIPT05:
17046 case eeSCRIPT06:
17047 case eeSCRIPT07:
17048 case eeSCRIPT08:
17049 case eeSCRIPT09:
17050 case eeSCRIPT10:
17051 case eeSCRIPT11:
17052 case eeSCRIPT12:
17053 case eeSCRIPT13:
17054 case eeSCRIPT14:
17055 case eeSCRIPT15:
17056 case eeSCRIPT16:
17057 case eeSCRIPT17:
17058 case eeSCRIPT18:
17059 case eeSCRIPT19:
17060 case eeSCRIPT20:
17061 {
17062 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17063 {
17064 e = new eScript((zfix)x,(zfix)y,id,clk);
17065 break;
17066 }
17067 else return 0;
17068 }
17069
17070 case eeFFRIENDLY01:
17071 case eeFFRIENDLY02:
17072 case eeFFRIENDLY03:
17073 case eeFFRIENDLY04:
17074 case eeFFRIENDLY05:
17075 case eeFFRIENDLY06:
17076 case eeFFRIENDLY07:
17077 case eeFFRIENDLY08:
17078 case eeFFRIENDLY09:
17079 case eeFFRIENDLY10:
17080 {
17081 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17082 {
17083 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17084 }
17085 else return 0;
17086
17087 }
17088
17089 case eeSPINTILE:
17090 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17091 break;
17092
17093 // and these enemies use the misc10/misc2 value
17094 case eeROCK:
17095 {
17096 switch(guysbuf[id&0xFFF].attributes[9])
17097 {
17098 case 1:
17099 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17100 break;
17101
17102 case 0:
17103 default:
17104 e = new eRock((zfix)x,(zfix)y,id,clk);
17105 break;
17106 }
17107
17108 break;
17109 }
17110
17111 case eeTRAP:
17112 {
17113 switch(guysbuf[id&0xFFF].attributes[1])
17114 {
17115 case 1:
17116 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17117 break;
17118
17119 case 0:
17120 default:
17121 e = new eTrap((zfix)x,(zfix)y,id,clk);
17122 break;
17123 }
17124
17125 break;
17126 }
17127
17128 case eeDONGO:
17129 {
17130 switch(guysbuf[id&0xFFF].attributes[9])
17131 {
17132 case 1:
17133 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17134 break;
17135
17136 case 0:
17137 default:
17138 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17139 break;
17140 }
17141
17142 break;
17143 }
17144
17145 case eeDIG:
17146 {
17147
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].attributes[9])
17148 {
17149 case 1:
17150 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17151 break;
17152
17153 4 case 0:
17154 default:
17155
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17156 4 break;
17157 }
17158
17159 4 break;
17160 }
17161
17162 case eePATRA:
17163 {
17164 switch(guysbuf[id&0xFFF].attributes[9])
17165 {
17166 case 1:
17167 if (get_qr(qr_HARDCODED_BS_PATRA))
17168 {
17169 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17170 break;
17171 }
17172 [[fallthrough]];
17173 case 0:
17174 default:
17175 e = new ePatra((zfix)x,(zfix)y,id,clk);
17176 break;
17177 }
17178
17179 break;
17180 }
17181
17182 case eeGUY:
17183 {
17184 switch(guysbuf[id&0xFFF].attributes[9])
17185 {
17186 case 1:
17187 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17188 break;
17189
17190 case 0:
17191 default:
17192 e = new eNPC((zfix)x,(zfix)y,id,clk);
17193 break;
17194 }
17195
17196 break;
17197 }
17198
17199 case eeNONE:
17200 if(guysbuf[id&0xFFF].attributes[9] ==1)
17201 {
17202 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17203 break;
17204 break;
17205 }
17206 [[fallthrough]];
17207 default:
17208
17209 return 0;
17210 }
17211
17212 1997 ret++; // Made one enemy.
17213
17214
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
1997 if(z && canfall(id))
17215 {
17216 7 e->z = (zfix)z;
17217 7 }
17218
17219
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 7 times.
1997 ((enemy*)e)->ceiling = (z && canfall(id));
17220 1997 e->setParent(parent);
17221
17222
1/2
✓ Branch 0 taken 1997 times.
✗ Branch 1 not taken.
1997 if(!guys.add(e))
17223 {
17224 return 0;
17225 }
17226
17227 // add segments of segmented enemies
17228 1997 int32_t c=0;
17229
17230
2/6
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1997 switch(guysbuf[id&0xFFF].family)
17231 {
17232 case eeMOLD:
17233 {
17234 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17235 id &= 0xFFF;
17236
17237 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17238 {
17239 //christ this is messy -DD
17240 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17241
17242 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17243 {
17244 al_trace("Moldorm segment %d could not be created!\n",i+1);
17245
17246 for(int32_t j=0; j<i+1; j++)
17247 guys.del(guys.Count()-1);
17248
17249 return 0;
17250 }
17251
17252 if(i>0)
17253 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17254
17255 ret++;
17256 }
17257
17258 break;
17259 }
17260
17261 case eeLANM:
17262 {
17263 id &= 0xFFF;
17264 int32_t shft = guysbuf[id].attributes[1];
17265 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17266
17267 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17268 {
17269 al_trace("Lanmola segment 1 could not be created!\n");
17270 guys.del(guys.Count()-1);
17271 return 0;
17272 }
17273
17274 ret++;
17275
17276 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17277 {
17278 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17279 {
17280 al_trace("Lanmola segment %d could not be created!\n",i+1);
17281
17282 for(int32_t j=0; j<i+1; j++)
17283 guys.del(guys.Count()-1);
17284
17285 return 0;
17286 }
17287
17288 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17289 ret++;
17290 }
17291 }
17292 break;
17293
17294 case eeMANHAN:
17295 1 id &= 0xFFF;
17296
17297
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17298 {
17299
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17300 {
17301 al_trace("Manhandla head %d could not be created!\n",i+1);
17302
17303 for(int32_t j=0; j<i+1; j++)
17304 {
17305 guys.del(guys.Count()-1);
17306 }
17307
17308 return 0;
17309 }
17310
17311 4 ret++;
17312 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17313 4 }
17314
17315 1 break;
17316
17317 case eeGLEEOK:
17318 {
17319 id &= 0xFFF;
17320
17321 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17322 {
17323 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
17324 {
17325 al_trace("Gleeok head %d could not be created!\n",i+1);
17326
17327 for(int32_t j=0; j<i+1; j++)
17328 {
17329 guys.del(guys.Count()-1);
17330 }
17331
17332 return false;
17333 }
17334
17335 c-=guysbuf[id].attributes[3];
17336 ret++;
17337 }
17338 }
17339 break;
17340
17341
17342 case eePATRA:
17343 {
17344 id &= 0xFFF;
17345 int32_t outeyes = 0;
17346
17347 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17348 {
17349 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17350 {
17351 al_trace("Patra outer eye %d could not be created!\n",i+1);
17352
17353 for(int32_t j=0; j<i+1; j++)
17354 guys.del(guys.Count()-1);
17355
17356 return 0;
17357 }
17358 else
17359 outeyes++;
17360
17361 ret++;
17362 }
17363
17364 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17365 {
17366 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17367 {
17368 al_trace("Patra inner eye %d could not be created!\n",i+1);
17369
17370 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17371 guys.del(guys.Count()-1);
17372
17373 return 0;
17374 }
17375
17376 ret++;
17377 }
17378
17379 break;
17380 }
17381 }
17382
17383
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 1997 times.
3998 for (int i = 0; i < ret; i++)
17384 {
17385 2001 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17386 2001 e->screen_spawned = screen;
17387 2001 }
17388
17389 1997 return ret;
17390 1997 }
17391
17392 // Returns number of enemies/segments created
17393 102042 int32_t addenemy_z(int32_t screen,int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
17394 {
17395 102042 int32_t realid = id&0xFFF;
17396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102042 times.
102042 if( realid > MAXGUYS )
17397 {
17398 return 0;
17399 }
17400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102042 times.
102042 if(id <= 0) return 0;
17401
17402 102042 int32_t ret = 0;
17403 102042 sprite *e=NULL;
17404
17405
28/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50091 times.
✓ Branch 4 taken 3942 times.
✓ Branch 5 taken 5212 times.
✓ Branch 6 taken 1825 times.
✓ Branch 7 taken 2797 times.
✓ Branch 8 taken 461 times.
✓ Branch 9 taken 11855 times.
✓ Branch 10 taken 5335 times.
✓ Branch 11 taken 4429 times.
✓ Branch 12 taken 986 times.
✓ Branch 13 taken 125 times.
✓ Branch 14 taken 617 times.
✓ Branch 15 taken 149 times.
✓ Branch 16 taken 168 times.
✓ Branch 17 taken 93 times.
✓ Branch 18 taken 418 times.
✓ Branch 19 taken 13 times.
✓ Branch 20 taken 731 times.
✓ Branch 21 taken 758 times.
✓ Branch 22 taken 7630 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 384 times.
✓ Branch 25 taken 2448 times.
✓ Branch 26 taken 251 times.
✓ Branch 27 taken 401 times.
✓ Branch 28 taken 291 times.
✓ Branch 29 taken 5 times.
✓ Branch 30 taken 533 times.
102042 switch(guysbuf[id&0xFFF].family)
17406 {
17407 //Fixme: possible enemy memory leak. (minor)
17408 case eeWALK:
17409
3/6
✓ Branch 0 taken 50091 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50091 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 50091 times.
✗ Branch 5 not taken.
50091 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17410 50091 break;
17411
17412 case eeLEV:
17413
3/6
✓ Branch 0 taken 3942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3942 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3942 times.
✗ Branch 5 not taken.
3942 e = new eLeever((zfix)x,(zfix)y,id,clk);
17414 3942 break;
17415
17416 case eeTEK:
17417
3/6
✓ Branch 0 taken 5212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5212 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5212 times.
✗ Branch 5 not taken.
5212 e = new eTektite((zfix)x,(zfix)y,id,clk);
17418 5212 break;
17419
17420 case eePEAHAT:
17421
3/6
✓ Branch 0 taken 1825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1825 times.
✗ Branch 5 not taken.
1825 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17422 1825 break;
17423
17424 case eeZORA:
17425
3/6
✓ Branch 0 taken 2797 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2797 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2797 times.
✗ Branch 5 not taken.
2797 e = new eZora((zfix)x,(zfix)y,id,clk);
17426 2797 break;
17427
17428 case eeGHINI:
17429
3/6
✓ Branch 0 taken 461 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461 times.
✗ Branch 5 not taken.
461 e = new eGhini((zfix)x,(zfix)y,id,clk);
17430 461 break;
17431
17432 case eeKEESE:
17433
3/6
✓ Branch 0 taken 11855 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11855 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11855 times.
✗ Branch 5 not taken.
11855 e = new eKeese((zfix)x,(zfix)y,id,clk);
17434 11855 break;
17435
17436 case eeWIZZ:
17437
3/6
✓ Branch 0 taken 5335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5335 times.
✗ Branch 5 not taken.
5335 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17438 5335 break;
17439
17440 case eePROJECTILE:
17441
3/6
✓ Branch 0 taken 4429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4429 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4429 times.
✗ Branch 5 not taken.
4429 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17442 4429 break;
17443
17444 case eeWALLM:
17445
3/6
✓ Branch 0 taken 986 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 986 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 986 times.
✗ Branch 5 not taken.
986 e = new eWallM((zfix)x,(zfix)y,id,clk);
17446 986 break;
17447
17448 case eeAQUA:
17449
3/6
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 125 times.
✗ Branch 5 not taken.
125 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17450 125 break;
17451
17452 case eeMOLD:
17453
6/12
✓ Branch 0 taken 617 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 617 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 617 times.
✓ Branch 6 taken 617 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 617 times.
✓ Branch 10 taken 617 times.
✗ Branch 11 not taken.
617 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17454 617 break;
17455
17456 case eeMANHAN:
17457
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
149 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17458 149 break;
17459
17460 case eeGLEEOK:
17461
7/12
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 168 times.
✓ Branch 6 taken 152 times.
✓ Branch 7 taken 16 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 152 times.
✓ Branch 10 taken 168 times.
✗ Branch 11 not taken.
168 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])));
17462 168 break;
17463
17464 case eeGHOMA:
17465
3/6
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93 times.
✗ Branch 5 not taken.
93 e = new eGohma((zfix)x,(zfix)y,id,clk);
17466 93 break;
17467
17468 case eeLANM:
17469
6/12
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 418 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 418 times.
✓ Branch 6 taken 418 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 418 times.
✓ Branch 10 taken 418 times.
✗ Branch 11 not taken.
418 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])));
17470 418 break;
17471
17472 case eeGANON:
17473
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13 times.
✗ Branch 5 not taken.
13 e = new eGanon((zfix)x,(zfix)y,id,clk);
17474 13 break;
17475
17476 case eeFAIRY:
17477
3/6
✓ Branch 0 taken 731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 731 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 731 times.
✗ Branch 5 not taken.
731 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17478 731 break;
17479
17480 case eeFIRE:
17481
3/6
✓ Branch 0 taken 758 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 758 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 758 times.
✗ Branch 5 not taken.
758 e = new eFire((zfix)x,(zfix)y,id,clk);
17482 758 break;
17483
17484 case eeOTHER:
17485
3/6
✓ Branch 0 taken 7630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7630 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7630 times.
✗ Branch 5 not taken.
7630 e = new eOther((zfix)x,(zfix)y,id,clk);
17486 7630 break;
17487
17488
17489 case eeSCRIPT01:
17490 case eeSCRIPT02:
17491 case eeSCRIPT03:
17492 case eeSCRIPT04:
17493 case eeSCRIPT05:
17494 case eeSCRIPT06:
17495 case eeSCRIPT07:
17496 case eeSCRIPT08:
17497 case eeSCRIPT09:
17498 case eeSCRIPT10:
17499 case eeSCRIPT11:
17500 case eeSCRIPT12:
17501 case eeSCRIPT13:
17502 case eeSCRIPT14:
17503 case eeSCRIPT15:
17504 case eeSCRIPT16:
17505 case eeSCRIPT17:
17506 case eeSCRIPT18:
17507 case eeSCRIPT19:
17508 case eeSCRIPT20:
17509 {
17510 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17511 {
17512 e = new eScript((zfix)x,(zfix)y,id,clk);
17513 break;
17514 }
17515 else return 0;
17516 }
17517
17518 case eeFFRIENDLY01:
17519 case eeFFRIENDLY02:
17520 case eeFFRIENDLY03:
17521 case eeFFRIENDLY04:
17522 case eeFFRIENDLY05:
17523 case eeFFRIENDLY06:
17524 case eeFFRIENDLY07:
17525 case eeFFRIENDLY08:
17526 case eeFFRIENDLY09:
17527 case eeFFRIENDLY10:
17528 {
17529 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17530 {
17531 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17532 }
17533 else return 0;
17534
17535 }
17536
17537 case eeSPINTILE:
17538
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17539 94 break;
17540
17541 // and these enemies use the misc10/misc2 value
17542 case eeROCK:
17543 {
17544
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 354 times.
384 switch(guysbuf[id&0xFFF].attributes[9])
17545 {
17546 case 1:
17547
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17548 30 break;
17549
17550 354 case 0:
17551 default:
17552
3/6
✓ Branch 0 taken 354 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354 times.
✗ Branch 5 not taken.
354 e = new eRock((zfix)x,(zfix)y,id,clk);
17553 354 break;
17554 }
17555
17556 384 break;
17557 }
17558
17559 case eeTRAP:
17560 {
17561
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1616 times.
2448 switch(guysbuf[id&0xFFF].attributes[1])
17562 {
17563 case 1:
17564
3/6
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
832 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17565 832 break;
17566
17567 1616 case 0:
17568 default:
17569
3/6
✓ Branch 0 taken 1616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1616 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1616 times.
✗ Branch 5 not taken.
1616 e = new eTrap((zfix)x,(zfix)y,id,clk);
17570 1616 break;
17571 }
17572
17573 2448 break;
17574 }
17575
17576 case eeDONGO:
17577 {
17578
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 203 times.
251 switch(guysbuf[id&0xFFF].attributes[9])
17579 {
17580 case 1:
17581
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17582 48 break;
17583
17584 203 case 0:
17585 default:
17586
3/6
✓ Branch 0 taken 203 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 203 times.
✗ Branch 5 not taken.
203 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17587 203 break;
17588 }
17589
17590 251 break;
17591 }
17592
17593 case eeDIG:
17594 {
17595
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 326 times.
✓ Branch 2 taken 75 times.
401 switch(guysbuf[id&0xFFF].attributes[9])
17596 {
17597 case 1:
17598
3/6
✓ Branch 0 taken 326 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 326 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 326 times.
✗ Branch 5 not taken.
326 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17599 326 break;
17600
17601 75 case 0:
17602 default:
17603
3/6
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✗ Branch 5 not taken.
75 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17604 75 break;
17605 }
17606
17607 401 break;
17608 }
17609
17610 case eePATRA:
17611 {
17612
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 102 times.
291 switch(guysbuf[id&0xFFF].attributes[9])
17613 {
17614 case 1:
17615
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if (get_qr(qr_HARDCODED_BS_PATRA))
17616 {
17617
3/6
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102 times.
✗ Branch 5 not taken.
102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17618 102 break;
17619 }
17620 [[fallthrough]];
17621 189 case 0:
17622 default:
17623
3/6
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 189 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 189 times.
✗ Branch 5 not taken.
189 e = new ePatra((zfix)x,(zfix)y,id,clk);
17624 189 break;
17625 }
17626
17627 291 break;
17628 }
17629
17630 case eeGUY:
17631 {
17632
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
5 switch(guysbuf[id&0xFFF].attributes[9])
17633 {
17634 case 1:
17635 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17636 break;
17637
17638 5 case 0:
17639 default:
17640
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 e = new eNPC((zfix)x,(zfix)y,id,clk);
17641 5 break;
17642 }
17643
17644 5 break;
17645 }
17646
17647 case eeNONE:
17648
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(guysbuf[id&0xFFF].attributes[9] ==1)
17649 {
17650
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17651 533 break;
17652 }
17653 [[fallthrough]];
17654 default:
17655
17656 return 0;
17657 }
17658
17659 102042 ret++; // Made one enemy.
17660
17661
4/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 101865 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 152 times.
102042 if(z && canfall(id))
17662 {
17663 152 e->z = (zfix)z;
17664 152 }
17665
17666
2/2
✓ Branch 0 taken 101865 times.
✓ Branch 1 taken 177 times.
102042 ((enemy*)e)->ceiling = (z && canfall(id));
17667
17668
1/2
✓ Branch 0 taken 102042 times.
✗ Branch 1 not taken.
102042 if(!guys.add(e))
17669 {
17670 return 0;
17671 }
17672
17673 // add segments of segmented enemies
17674 102042 int32_t c=0;
17675
17676
6/6
✓ Branch 0 taken 100399 times.
✓ Branch 1 taken 617 times.
✓ Branch 2 taken 418 times.
✓ Branch 3 taken 149 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 291 times.
102042 switch(guysbuf[id&0xFFF].family)
17677 {
17678 case eeMOLD:
17679 {
17680 617 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17681 617 id &= 0xFFF;
17682
17683
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3762 times.
✓ Branch 2 taken 3762 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3762 times.
✓ Branch 6 taken 3145 times.
✓ Branch 7 taken 617 times.
3762 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].attributes[0])); i++)
17684 {
17685 //christ this is messy -DD
17686 3145 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
17687
17688
4/8
✓ Branch 0 taken 3145 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3145 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3145 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3145 times.
✗ Branch 7 not taken.
3145 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
17689 {
17690 al_trace("Moldorm segment %d could not be created!\n",i+1);
17691
17692 for(int32_t j=0; j<i+1; j++)
17693 guys.del(guys.Count()-1);
17694
17695 return 0;
17696 }
17697
17698
2/2
✓ Branch 0 taken 617 times.
✓ Branch 1 taken 2528 times.
3145 if(i>0)
17699 2528 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17700
17701 3145 ret++;
17702 3145 }
17703
17704 617 break;
17705 }
17706
17707 case eeLANM:
17708 {
17709 418 id &= 0xFFF;
17710 418 int32_t shft = guysbuf[id].attributes[1];
17711 418 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
17712
17713
4/8
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 418 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 418 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 418 times.
✗ Branch 7 not taken.
418 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
17714 {
17715 al_trace("Lanmola segment 1 could not be created!\n");
17716 guys.del(guys.Count()-1);
17717 return 0;
17718 }
17719
17720 418 ret++;
17721
17722
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2257 times.
✓ Branch 6 taken 1839 times.
✓ Branch 7 taken 418 times.
2257 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].attributes[0])); i++)
17723 {
17724
4/8
✓ Branch 0 taken 1839 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1839 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1839 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1839 times.
✗ Branch 7 not taken.
1839 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
17725 {
17726 al_trace("Lanmola segment %d could not be created!\n",i+1);
17727
17728 for(int32_t j=0; j<i+1; j++)
17729 guys.del(guys.Count()-1);
17730
17731 return 0;
17732 }
17733
17734 1839 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
17735 1839 ret++;
17736 1839 }
17737 }
17738 418 break;
17739
17740 case eeMANHAN:
17741 149 id &= 0xFFF;
17742
17743
2/2
✓ Branch 0 taken 688 times.
✓ Branch 1 taken 149 times.
837 for(int32_t i=0; i<((!(guysbuf[id].attributes[1]))?4:8); i++)
17744 {
17745
4/8
✓ Branch 0 taken 688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 688 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 688 times.
✗ Branch 7 not taken.
688 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
17746 {
17747 al_trace("Manhandla head %d could not be created!\n",i+1);
17748
17749 for(int32_t j=0; j<i+1; j++)
17750 {
17751 guys.del(guys.Count()-1);
17752 }
17753
17754 return 0;
17755 }
17756
17757 688 ret++;
17758 688 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].attributes[0];
17759 688 }
17760
17761 149 break;
17762
17763 case eeGLEEOK:
17764 {
17765 168 id &= 0xFFF;
17766 168 eGleeok* parent = (eGleeok*)e;
17767
17768
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 701 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 32 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 533 times.
✓ Branch 7 taken 168 times.
701 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].attributes[0])); i++)
17769 {
17770
3/6
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 533 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 533 times.
✗ Branch 5 not taken.
533 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
17771
1/2
✓ Branch 0 taken 533 times.
✗ Branch 1 not taken.
533 if(!guys.add(head))
17772 {
17773 al_trace("Gleeok head %d could not be created!\n",i+1);
17774
17775 for(int32_t j=0; j<i+1; j++)
17776 {
17777 guys.del(guys.Count()-1);
17778 }
17779
17780 return false;
17781 }
17782
17783 533 head->necktile=parent->necktile;
17784 533 head->dummy_int[1]=parent->necktile;
17785
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 112 times.
533 if(get_qr(qr_NEWENEMYTILES))
17786 {
17787 421 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
17788 421 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
17789 421 }
17790 else
17791 {
17792 112 head->dummy_int[2]=parent->necktile+1; //connected head tile
17793 112 head->dummy_int[3]=parent->necktile+2; //flying head tile
17794 }
17795 533 head->tile = head->dummy_int[2];
17796
17797 533 c-=guysbuf[id].attributes[3];
17798 533 ret++;
17799 533 }
17800 }
17801 168 break;
17802
17803
17804 case eePATRA:
17805 {
17806 291 id &= 0xFFF;
17807 291 int32_t outeyes = 0;
17808
17809
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2239 times.
✓ Branch 2 taken 1948 times.
✓ Branch 3 taken 291 times.
2239 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[0]); i++)
17810 {
17811
10/22
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 1336 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 612 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 612 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 612 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1336 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1336 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1336 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1336 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
1948 if(!((guysbuf[id].attributes[9] &&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
17812 {
17813 al_trace("Patra outer eye %d could not be created!\n",i+1);
17814
17815 for(int32_t j=0; j<i+1; j++)
17816 guys.del(guys.Count()-1);
17817
17818 return 0;
17819 }
17820 else
17821 1948 outeyes++;
17822
17823 1948 ret++;
17824 1948 }
17825
17826
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 603 times.
✓ Branch 2 taken 312 times.
✓ Branch 3 taken 291 times.
603 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].attributes[1]); i++)
17827 {
17828
4/8
✓ Branch 0 taken 312 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 312 times.
✗ Branch 7 not taken.
312 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
17829 {
17830 al_trace("Patra inner eye %d could not be created!\n",i+1);
17831
17832 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
17833 guys.del(guys.Count()-1);
17834
17835 return 0;
17836 }
17837
17838 312 ret++;
17839 312 }
17840
17841 291 break;
17842 }
17843 }
17844
17845
2/2
✓ Branch 0 taken 110925 times.
✓ Branch 1 taken 102042 times.
212967 for (int i = 0; i < ret; i++)
17846 {
17847 110925 enemy* e = (enemy*)guys.spr(guys.Count() - 1 - i);
17848 110925 e->screen_spawned = screen;
17849 110925 }
17850
17851 102042 return ret;
17852 102042 }
17853
17854 2059282 bool isjumper(int32_t id)
17855 {
17856
2/4
✓ Branch 0 taken 2059282 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2059282 times.
2059282 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17857 {
17858 return false;
17859 }
17860
3/3
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1953404 times.
✓ Branch 2 taken 105869 times.
2059282 switch(guysbuf[id&0xFFF].family)
17861 {
17862 case eeROCK:
17863 case eeTEK:
17864 9 return true;
17865
17866 case eeWALK:
17867
3/4
✓ Branch 0 taken 105869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 93604 times.
105869 if(guysbuf[id&0xFFF].attributes[8] == e9tVIRE || guysbuf[id & 0xFFF].attributes[8] == e9tPOLSVOICE) return true;
17868 93604 }
17869
17870 2047008 return false;
17871 2059282 }
17872
17873
17874 8068 bool isfixedtogrid(int32_t id)
17875 {
17876
2/4
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8068 times.
8068 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17877 {
17878 return false;
17879 }
17880
1/2
✓ Branch 0 taken 8068 times.
✗ Branch 1 not taken.
8068 switch(guysbuf[id&0xFFF].family)
17881 {
17882 case eeWALK:
17883 case eeLEV:
17884 case eeZORA:
17885 case eeDONGO:
17886 case eeGANON:
17887 case eeROCK:
17888 case eeGLEEOK:
17889 case eeAQUA:
17890 case eeLANM:
17891 return true;
17892 }
17893
17894 8068 return false;
17895 8068 }
17896
17897 // Can't fall, can have Z value.
17898 52191265 bool isflier(int32_t id)
17899 {
17900
3/4
✓ Branch 0 taken 52191265 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110310 times.
✓ Branch 3 taken 52080955 times.
52191265 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17901 {
17902 110310 return false;
17903 }
17904
2/2
✓ Branch 0 taken 6494922 times.
✓ Branch 1 taken 45586033 times.
52080955 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
17905 {
17906 case eePEAHAT:
17907 case eeKEESE:
17908 case eePATRA:
17909 case eeFAIRY:
17910 case eeGHINI:
17911
17912 // Could theoretically have their Z set by a script
17913 case eeFIRE:
17914 6494922 return true;
17915 break;
17916 }
17917
17918 45586033 return false;
17919 52191265 }
17920
17921 // Can't have Z position
17922 4046103 bool never_in_air(int32_t id)
17923 {
17924
2/4
✓ Branch 0 taken 4046103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4046103 times.
4046103 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17925 {
17926 return false;
17927 }
17928
2/2
✓ Branch 0 taken 4036553 times.
✓ Branch 1 taken 9550 times.
4046103 switch(guysbuf[id&0xFFF].family)
17929 {
17930 case eeMANHAN:
17931 case eeMOLD:
17932 case eeLANM:
17933 case eeGLEEOK:
17934 case eeZORA:
17935 case eeLEV:
17936 case eeAQUA:
17937 case eeROCK:
17938 case eeGANON:
17939 case eeTRAP:
17940 case eePROJECTILE:
17941 case eeSPINTILE:
17942 9550 return true;
17943 }
17944
17945 4036553 return false;
17946 4046103 }
17947
17948 2248208 bool canfall(int32_t id)
17949 {
17950
3/4
✓ Branch 0 taken 2248208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 2248162 times.
2248208 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17951 {
17952 46 return false;
17953 }
17954
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2248122 times.
✓ Branch 2 taken 40 times.
2248162 switch(guysbuf[id&0xFFF].family)
17955 {
17956 case eeGUY:
17957 {
17958
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(id < eOCTO1S)
17959 40 return false;
17960
17961 switch(guysbuf[id&0xFFF].attributes[9])
17962 {
17963 case 1:
17964 case 2:
17965 return true;
17966
17967 case 0:
17968 case 3:
17969 default:
17970 return false;
17971 }
17972
17973 case eeGHOMA:
17974 case eeDIG:
17975 return false;
17976 }
17977 }
17978
17979
17980
4/4
✓ Branch 0 taken 2239686 times.
✓ Branch 1 taken 8436 times.
✓ Branch 2 taken 180404 times.
✓ Branch 3 taken 2059282 times.
2248122 return !never_in_air(id) && !isflier(id) && !isjumper(id);
17981 2248208 }
17982
17983 73741723 bool enemy::enemycanfall(int32_t id, bool checkgrav)
17984 {
17985
3/4
✓ Branch 0 taken 73741723 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89584 times.
✓ Branch 3 taken 73652139 times.
73741723 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
17986 {
17987 89584 return false;
17988 }
17989 //Z_scripterrlog("canfall family is %d:\n", family);
17990 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & move_obeys_grav ? "true" : "false");
17991 //if ( family == eeFIRE && id >= eSTART )
17992 //{
17993 // Z_scripterrlog("eeFire\n");
17994 // return moveflags & move_obeys_grav; //'Other' enemy class, used by scripts. -Z
17995 //}
17996
17997 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
17998
17999
3/3
✓ Branch 0 taken 427447 times.
✓ Branch 1 taken 71149984 times.
✓ Branch 2 taken 2074708 times.
73652139 switch(guysbuf[id&0xFFF].family)
18000 {
18001 case eeGUY:
18002 {
18003
1/2
✓ Branch 0 taken 2074708 times.
✗ Branch 1 not taken.
2074708 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18004 2074708 return false;
18005
18006 switch(guysbuf[id&0xFFF].attributes[9]) //I'm unsure what these specify off-hand. Needs better comments. -Z
18007 {
18008 case 1:
18009 case 2:
18010 return true;
18011
18012 case 0:
18013 case 3:
18014 default:
18015 return false;
18016 }
18017
18018 case eeGHOMA:
18019 case eeDIG:
18020 427447 return false;
18021 }
18022 }
18023
18024
2/2
✓ Branch 0 taken 38948888 times.
✓ Branch 1 taken 32201096 times.
71149984 if(!checkgrav) return true;
18025 38948888 return (moveflags & move_obeys_grav);
18026
18027 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18028 // {
18029 // if ( moveflags & move_obeys_grav ) return true;
18030 // else return false;
18031 // }
18032 // else
18033 // {
18034 // return (moveflags & move_obeys_grav);
18035 // }
18036 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18037 73741723 }
18038
18039 1269 void addfires()
18040 {
18041
2/2
✓ Branch 0 taken 814 times.
✓ Branch 1 taken 455 times.
1269 if(!get_qr(qr_NOGUYFIRES))
18042 {
18043 2275 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
18044 455 int32_t bs = get_qr(qr_BSZELDA);
18045 910 addguy(dx+(bs? 64: 72),dy+64,gFIRE,-17,false,nullptr);
18046 910 addguy(dx+(bs?176:168),dy+64,gFIRE,-18,false,nullptr);
18047 455 }
18048 1269 }
18049
18050 // This function runs one time for every screen on the first frame of a region being loaded.
18051 // It handles spawning screen guys (not the enemies), item, and room-specific sprites.
18052 36987 static void loadguys(mapscr* scr)
18053 {
18054 36987 int screen = scr->screen;
18055 36987 byte Guy=0;
18056 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18057 // Else use mITEM and ipONETIME
18058 36987 int32_t mf = (screen>=128) ? mSPECIALITEM : mITEM;
18059 36987 int32_t onetime = (screen>=128) ? ipONETIME2 : ipONETIME;
18060
18061 36987 mapscr* guyscr = scr;
18062
4/4
✓ Branch 0 taken 904 times.
✓ Branch 1 taken 36083 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 429 times.
36987 if(screen>=128 && DMaps[cur_dmap].flags&dmfGUYCAVES)
18063 {
18064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429 times.
429 if(DMaps[cur_dmap].flags&dmfCAVES)
18065 {
18066 429 Guy=special_warp_return_scr->guy;
18067 429 guyscr = special_warp_return_scr;
18068 429 }
18069 429 }
18070 else
18071 {
18072 36558 Guy=scr->guy;
18073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36558 times.
36558 if (game->get_regionmapping() == REGION_MAPPING_FULL)
18074 36558 mark_visited(screen);
18075 }
18076
18077 113873 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18078
18079 36987 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18080 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18081
4/4
✓ Branch 0 taken 3854 times.
✓ Branch 1 taken 33133 times.
✓ Branch 2 taken 2541 times.
✓ Branch 3 taken 1313 times.
36987 if(Guy && ((screen>=128) == !!(DMaps[cur_dmap].flags&dmfGUYCAVES)))
18082 {
18083
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1302 times.
1313 if(scr->room==rZELDA)
18084 {
18085 22 addguy(dx+120,dy+72,Guy,-15,true,guyscr);
18086 11 guys.spr(0)->hxofs=1000;
18087 33 addenemy(screen,dx+128,dy+96,eFIRE,-15);
18088 33 addenemy(screen,dx+112,dy+96,eFIRE,-15);
18089 33 addenemy(screen,dx+96,dy+120,eFIRE,-15);
18090 33 addenemy(screen,dx+144,dy+120,eFIRE,-15);
18091 11 return;
18092 }
18093
18094
2/2
✓ Branch 0 taken 1298 times.
✓ Branch 1 taken 4 times.
2600 bool ffire = oldguy
18095
2/2
✓ Branch 0 taken 1269 times.
✓ Branch 1 taken 29 times.
1298 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18096 4 : (guyscr->roomflags&RFL_GUYFIRES);
18097
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1269 times.
1302 if(ffire)
18098 1269 addfires();
18099
18100
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 423 times.
1302 if(screen>=128)
18101
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
436 if(getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))
18102 13 Guy=0;
18103
18104
4/6
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 1089 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 45 times.
1302 switch(scr->room)
18105 {
18106 case rSP_ITEM:
18107 case rGRUMBLE:
18108 case rBOMBS:
18109 case rARROWS:
18110 case rSWINDLE:
18111 case rMUPGRADE:
18112 case rLEARNSLASH:
18113 case rTAKEONE:
18114
8/8
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 49 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 42 times.
167 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18115 55 Guy=0;
18116
18117 167 break;
18118
18119 case rREPAIR:
18120 if (get_qr(qr_OLD_DOORREPAIR)) break;
18121 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18122 Guy=0;
18123
18124 break;
18125 case rRP_HC:
18126 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18127 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18128 Guy=0;
18129
18130 break;
18131 case rMONEY:
18132
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18133 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, mf)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag(screen, 32) && !(scr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18134 Guy=0;
18135
18136 break;
18137
18138 case rTRIFORCE:
18139 {
18140 45 int32_t tc = TriforceCount();
18141
18142
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 34 times.
45 if(get_qr(qr_4TRI))
18143 {
18144
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18145 10 Guy=0;
18146 9 }
18147 else
18148 {
18149
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 1 times.
34 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18150 33 Guy=0;
18151 }
18152 }
18153 43 break;
18154 }
18155
18156
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 1193 times.
1300 if(Guy)
18157 {
18158
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1160 times.
1193 if(ffire)
18159 1160 blockpath=true;
18160
18161
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 783 times.
1193 if(screen<128)
18162 783 sfx(WAV_SCALE);
18163
18164
6/6
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 728 times.
✓ Branch 2 taken 465 times.
✓ Branch 3 taken 728 times.
✓ Branch 4 taken 110 times.
✓ Branch 5 taken 355 times.
2386 addguy(dx+120,dy+64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true, guyscr);
18165 1193 Hero.Freeze();
18166 1193 }
18167 1300 }
18168
5/6
✓ Branch 0 taken 33857 times.
✓ Branch 1 taken 1817 times.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 33786 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1817 times.
35674 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18169 {
18170 71 sfx(WAV_SCALE);
18171 142 addguy(dx+120,dy+62,gFAIRY,-14,false,guyscr);
18172 71 }
18173
18174 110922 loaditem(scr, dx, dy);
18175
18176 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18177 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18178
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36955 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 15 times.
36974 if (scr->room==r10RUPIES && !getmapflag(screen, mf))
18179 {
18180
2/2
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 15 times.
165 for(int32_t i=0; i<10; i++)
18181 300 additem(dx+ten_rupies_x[i],dy+ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18182 15 }
18183 36985 }
18184
18185 35743 void loadguys()
18186 {
18187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35743 times.
35743 if (loaded_guys)
18188 return;
18189
18190 35743 loaded_guys = true;
18191 35743 repaircharge = 0;
18192 35743 adjustmagic = false;
18193 35743 learnslash = false;
18194
2/2
✓ Branch 0 taken 107229 times.
✓ Branch 1 taken 35743 times.
142972 for (int32_t i=0; i<3; i++)
18195 {
18196 107229 prices[i] = 0;
18197 107229 }
18198
18199 72730 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18200 36987 get_screen_state(scr->screen).item_state = ScreenItemState::None;
18201 36987 loadguys(scr);
18202 36987 });
18203 35743 }
18204
18205 36993 void loaditem(mapscr* scr, int offx, int offy)
18206 {
18207 36993 int screen = scr->screen;
18208 36993 byte Item = 0;
18209
18210
2/2
✓ Branch 0 taken 36089 times.
✓ Branch 1 taken 904 times.
36993 if(screen<128)
18211 {
18212 36089 Item=scr->item;
18213
18214
4/4
✓ Branch 0 taken 1579 times.
✓ Branch 1 taken 34510 times.
✓ Branch 2 taken 32881 times.
✓ Branch 3 taken 3208 times.
36089 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
18215 {
18216
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 3149 times.
3208 if(scr->flags8&fSECRETITEM)
18217 59 screen_item_set_state(screen, ScreenItemState::WhenTriggerSecrets);
18218
2/2
✓ Branch 0 taken 1160 times.
✓ Branch 1 taken 1989 times.
3149 else if(scr->flags&fITEM)
18219 1160 screen_item_set_state(screen, ScreenItemState::WhenKillEnemies);
18220
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 1880 times.
1989 else if(scr->flags11&efCARRYITEM)
18221 109 screen_item_set_state(screen, ScreenItemState::MustGiveToEnemy); // Will be set to CarriedByEnemy in roaming_item
18222 else
18223 {
18224 1880 int x = scr->itemx;
18225
3/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1865 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
1880 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18226 -170 :
18227 1880 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18228
3/6
✓ Branch 0 taken 1880 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1880 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1880 times.
✗ Branch 5 not taken.
3760 add_item_for_screen(screen, new item(offx + x, offy + y,
18229
6/10
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 1865 times.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1865 times.
✗ Branch 9 not taken.
1880 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18230
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1776 times.
1880 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
18231 1880 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18232 }
18233 3208 }
18234 36089 }
18235
2/2
✓ Branch 0 taken 429 times.
✓ Branch 1 taken 475 times.
904 else if(!(DMaps[cur_dmap].flags&dmfCAVES))
18236 {
18237
4/6
✓ Branch 0 taken 475 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 16 times.
491 if((!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (special_warp_return_scr->flags9&fBELOWRETURN)) && special_warp_return_scr->room==rSP_ITEM
18238
4/4
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 147 times.
475 && (screen==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
18239 {
18240 163 Item = special_warp_return_scr->catchall;
18241
18242
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 162 times.
163 if(Item)
18243 {
18244 162 int x = scr->itemx;
18245
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 int y = scr->flags7&fITEMFALLS && isSideViewGravity() ?
18246 -170 :
18247 162 scr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1);
18248
3/6
✓ Branch 0 taken 162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162 times.
✗ Branch 5 not taken.
324 add_item_for_screen(screen, new item(offx + x, offy + y,
18249
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 162 times.
✗ Branch 9 not taken.
162 (scr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18250 162 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
18251 162 }
18252 163 }
18253 475 }
18254 36993 }
18255
18256 953 void never_return(int32_t screen, int32_t index)
18257 {
18258
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 191 times.
953 if(!get_qr(qr_KILLALL))
18259 191 goto doit;
18260
18261
2/2
✓ Branch 0 taken 2288 times.
✓ Branch 1 taken 325 times.
2613 for(int32_t i=0; i<guys.Count(); i++)
18262
4/4
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 1312 times.
✓ Branch 2 taken 539 times.
✓ Branch 3 taken 437 times.
2288 if(((((enemy*)guys.spr(i))->d->flags)&guy_never_return) && i!=index)
18263 {
18264 437 goto dontdoit;
18265 325 }
18266
18267 doit:
18268 516 setmapflag(get_scr(screen), mNEVERRET);
18269 dontdoit:
18270 953 return;
18271 }
18272
18273 63668 bool slowguy(int32_t id)
18274 {
18275
2/4
✓ Branch 0 taken 63668 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63668 times.
63668 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18276 {
18277 return false;
18278 }
18279
18280 63668 id = id&0xFFF;
18281
18282
2/2
✓ Branch 0 taken 54055 times.
✓ Branch 1 taken 9613 times.
63668 switch(id)
18283 {
18284 case eOCTO1S:
18285 case eOCTO2S:
18286 case eOCTO1F:
18287 case eOCTO2F:
18288 case eLEV1:
18289 case eLEV2:
18290 case eROCK:
18291 case eBOULDER:
18292 9613 return true;
18293 }
18294
18295 54055 return false;
18296 63668 }
18297
18298 83281 static bool ok2add(mapscr* scr, int32_t id)
18299 {
18300
2/4
✓ Branch 0 taken 83281 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83281 times.
83281 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18301 {
18302 return false;
18303 }
18304
18305 83281 id = id&0xFFF;
18306
18307
4/4
✓ Branch 0 taken 826 times.
✓ Branch 1 taken 82455 times.
✓ Branch 2 taken 461 times.
✓ Branch 3 taken 365 times.
83281 if(getmapflag(scr, mNEVERRET) && (guysbuf[id].flags & guy_never_return))
18308 461 return false;
18309
18310
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 82180 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 200 times.
82820 switch(guysbuf[id].family)
18311 {
18312 // I added a special case for shooters because having traps on the same screen
18313 // was preventing them from spawning due to TMPNORET. This means they will
18314 // never stay dead, though, so it may not be the best solution. - Saf
18315 case eePROJECTILE:
18316 376 return true;
18317
18318
18319 case eeDIG:
18320 {
18321
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 74 times.
200 switch(guysbuf[id].attributes[9])
18322 {
18323 case 1:
18324
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 47 times.
126 if(!get_qr(qr_NOTMPNORET))
18325 79 return !getmapflag(scr, mTMPNORET);
18326
18327 47 return true;
18328
18329 74 case 0:
18330 default:
18331 74 return true;
18332 }
18333 }
18334 case eeGANON:
18335 case eeTRAP:
18336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
128 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
18337
4/4
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 64 times.
64 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
18338 [[fallthrough]];
18339 default:
18340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82180 times.
82180 if (guysbuf[id].flags&guy_ignoretmpnr) return true;
18341 82180 break;
18342 }
18343
18344
2/2
✓ Branch 0 taken 20980 times.
✓ Branch 1 taken 61200 times.
82180 if(!get_qr(qr_NOTMPNORET))
18345 61200 return !getmapflag(scr, mTMPNORET);
18346
18347 20980 return true;
18348 83281 }
18349
18350 1634103 static void activate_fireball_statue(const rpos_handle_t& rpos_handle)
18351 {
18352
3/4
✓ Branch 0 taken 288841 times.
✓ Branch 1 taken 1345262 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288841 times.
1634103 if (!(rpos_handle.scr->flags11&efFIREBALLS) || statueID<0)
18353 {
18354 1345262 return;
18355 }
18356
18357 288841 int32_t ctype = rpos_handle.ctype();
18358
6/6
✓ Branch 0 taken 287333 times.
✓ Branch 1 taken 1508 times.
✓ Branch 2 taken 286018 times.
✓ Branch 3 taken 1315 times.
✓ Branch 4 taken 1213 times.
✓ Branch 5 taken 284805 times.
288841 if (ctype != cL_STATUE && ctype != cR_STATUE && ctype != cC_STATUE) return;
18359
18360 12108 auto [x, y] = rpos_handle.xy();
18361
18362 4036 int32_t cx=-1000, cy=-1000;
18363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(!isfixedtogrid(statueID))
18364 {
18365
2/2
✓ Branch 0 taken 1508 times.
✓ Branch 1 taken 2528 times.
4036 if(ctype==cL_STATUE)
18366 {
18367 1508 cx=x+4;
18368 1508 cy=y+7;
18369 1508 }
18370
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 1213 times.
2528 else if(ctype==cR_STATUE)
18371 {
18372 1315 cx=x-8;
18373 1315 cy=y-1;
18374 1315 }
18375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1213 times.
1213 else if(ctype==cC_STATUE)
18376 {
18377 1213 cx=x;
18378 1213 cy=y;
18379 1213 }
18380 4036 }
18381 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
18382 {
18383 cx=x;
18384 cy=y;
18385 }
18386
18387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4036 times.
4036 if(cx!=-1000) // No point creating it if this is false
18388 {
18389
2/2
✓ Branch 0 taken 9754 times.
✓ Branch 1 taken 4032 times.
13786 for(int32_t j=0; j<guys.Count(); j++)
18390 {
18391
4/4
✓ Branch 0 taken 1698 times.
✓ Branch 1 taken 8056 times.
✓ Branch 2 taken 1694 times.
✓ Branch 3 taken 4 times.
9754 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
18392 {
18393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
18394 4 return; // No point deleting it. A script might be toying with it in some way.
18395 else
18396 guys.del(j);
18397 }
18398 9750 }
18399
18400 4032 addenemy(rpos_handle.screen, cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
18401 4032 }
18402 1634103 }
18403
18404 34332 static void activate_fireball_statues(mapscr* scr)
18405 {
18406
2/2
✓ Branch 0 taken 32913 times.
✓ Branch 1 taken 1419 times.
34332 if (!(scr->flags11&efFIREBALLS))
18407 {
18408 32913 return;
18409 }
18410
18411 251163 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18412 249744 activate_fireball_statue(rpos_handle);
18413 249744 });
18414 34332 }
18415
18416 35015 void load_default_enemies(mapscr* scr)
18417 {
18418 35015 int screen = scr->screen;
18419 40448 auto [dx, dy] = translate_screen_coordinates_to_world(screen);
18420
18421 35015 wallm_load_clk=frame-80;
18422
18423
2/2
✓ Branch 0 taken 33119 times.
✓ Branch 1 taken 1896 times.
35015 if(scr->flags11&efZORA)
18424 {
18425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1896 times.
1896 if(zoraID>=0)
18426 5688 addenemy(screen, dx - 16, dy - 16, zoraID, 0);
18427 1896 }
18428
18429
2/2
✓ Branch 0 taken 34841 times.
✓ Branch 1 taken 174 times.
35015 if(scr->flags11&efTRAP4)
18430 {
18431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if(cornerTrapID>=0)
18432 {
18433 522 addenemy(screen, dx + 32, dy + 32, cornerTrapID, -14);
18434 522 addenemy(screen, dx + 208, dy + 32, cornerTrapID, -14);
18435 522 addenemy(screen, dx + 32, dy + 128, cornerTrapID, -14);
18436 522 addenemy(screen, dx + 208, dy + 128, cornerTrapID, -14);
18437 174 }
18438 174 }
18439
18440 6197655 for_every_rpos_in_screen_layer0(scr, [&](const rpos_handle_t& rpos_handle) {
18441 6162640 int32_t ctype = rpos_handle.ctype();
18442 6162640 int32_t cflag = rpos_handle.sflag();
18443 6162640 int32_t cflag_i = rpos_handle.cflag();
18444
18445
4/6
✓ Branch 0 taken 6162640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6162294 times.
✓ Branch 3 taken 346 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6162294 times.
6162640 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
18446 {
18447 346 auto [x, y] = rpos_handle.xy();
18448
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 336 times.
346 if(trapLOSHorizontalID>=0)
18449 1008 addenemy(screen, x, y, trapLOSHorizontalID, -14);
18450 346 }
18451
4/6
✓ Branch 0 taken 6162294 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6162088 times.
✓ Branch 3 taken 206 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6162088 times.
6162294 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
18452 {
18453 206 auto [x, y] = rpos_handle.xy();
18454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if(trapLOSVerticalID>=0)
18455 618 addenemy(screen, x, y, trapLOSVerticalID, -14);
18456 206 }
18457
4/6
✓ Branch 0 taken 6162088 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6161810 times.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6161810 times.
6162088 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
18458 {
18459 278 auto [x, y] = rpos_handle.xy();
18460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(trapLOS4WayID>=0)
18461 {
18462
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 278 times.
834 if(addenemy(screen, x, y, trapLOS4WayID, -14))
18463 278 guys.spr(guys.Count()-1)->dummy_int[1]=2;
18464 278 }
18465 278 }
18466
4/6
✓ Branch 0 taken 6161810 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6161411 times.
✓ Branch 3 taken 399 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6161411 times.
6161810 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
18467 {
18468 399 auto [x, y] = rpos_handle.xy();
18469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 if(trapConstantHorizontalID>=0)
18470 1197 addenemy(screen, x, y, trapConstantHorizontalID, -14);
18471 399 }
18472
4/6
✓ Branch 0 taken 6161411 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6160978 times.
✓ Branch 3 taken 433 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6160978 times.
6161411 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
18473 {
18474 433 auto [x, y] = rpos_handle.xy();
18475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if(trapConstantVerticalID>=0)
18476 1299 addenemy(screen, x, y, trapConstantVerticalID, -14);
18477 433 }
18478
18479
1/2
✓ Branch 0 taken 6162640 times.
✗ Branch 1 not taken.
6162640 if(ctype==cSPINTILE1)
18480 {
18481 awaken_spinning_tile(rpos_handle);
18482 }
18483 6162640 });
18484
18485
2/2
✓ Branch 0 taken 34963 times.
✓ Branch 1 taken 52 times.
35015 if(scr->flags11&efTRAP2)
18486 {
18487
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if(centerTrapID>=-1)
18488 {
18489
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if(addenemy(screen, 64, 80, centerTrapID, -14))
18490 52 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18491
18492
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if(addenemy(screen, 176, 80, centerTrapID, -14))
18493 52 guys.spr(guys.Count()-1)->dummy_int[1]=1;
18494 52 }
18495 52 }
18496
18497
2/2
✓ Branch 0 taken 34932 times.
✓ Branch 1 taken 83 times.
35015 if(scr->flags11&efROCKS)
18498 {
18499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(rockID>=0)
18500 {
18501 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18502 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18503 166 addenemy(screen, dx + (zc_oldrand()&0xF0), 0, rockID, 0);
18504 83 }
18505 83 }
18506 35015 }
18507
18508 #define SLOPE_STAGE_COMBOS 0
18509 #define SLOPE_STAGE_FFCS 1
18510 #define SLOPE_STAGE_COMBOS_BORDERING_SCREENS 2
18511
18512 20909214 static slope_id_t create_slope_id(int stage, int arg1, int arg2)
18513 {
18514
2/2
✓ Branch 0 taken 4645463 times.
✓ Branch 1 taken 16263751 times.
20909214 if (stage == SLOPE_STAGE_COMBOS)
18515 16263751 return (region_num_rpos*arg1)+arg2;
18516
2/2
✓ Branch 0 taken 4500554 times.
✓ Branch 1 taken 144909 times.
4645463 if (stage == SLOPE_STAGE_FFCS)
18517 4500554 return (region_num_rpos*7)+arg1;
18518
1/2
✓ Branch 0 taken 144909 times.
✗ Branch 1 not taken.
144909 if (stage == SLOPE_STAGE_COMBOS_BORDERING_SCREENS)
18519 144909 return (region_num_rpos*7 + MAX_FFCID+1)+arg1*7*(16 * 2 + 11 * 2) + arg2;
18520 // TODO: what about FFCs from bordering screens?
18521
18522 assert(false);
18523 return 0;
18524 20909214 }
18525
18526 16263751 void update_slope_combopos(const rpos_handle_t& rpos_handle)
18527 {
18528 16263751 mapscr* s = rpos_handle.scr;
18529 16263751 auto& cmb = rpos_handle.combo();
18530
18531 16263751 auto id = create_slope_id(SLOPE_STAGE_COMBOS, rpos_handle.layer, (int)rpos_handle.rpos);
18532 16263751 auto it = slopes.find(id);
18533
18534 16263751 bool wasSlope = it!=slopes.end();
18535 16263751 bool isSlope = cmb.type == cSLOPE;
18536
18537
3/4
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 16263615 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
16263751 if(isSlope && !wasSlope)
18538 {
18539 272 auto [x, y] = rpos_handle.xy();
18540 272 slopes.try_emplace(id, &(s->data[rpos_handle.pos]), nullptr, -1, x, y);
18541 136 }
18542
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16263615 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16263615 else if(wasSlope && !isSlope)
18543 {
18544 slopes.erase(it);
18545 }
18546 16263751 }
18547
18548 144909 static void update_slope_combopos_bordering_screen(int dir, int slope_count, int cid, bool is_slope, int offx, int offy)
18549 {
18550 144909 auto id = create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS, dir, slope_count);
18551 144909 auto it = slopes.find(id);
18552
18553 144909 bool wasSlope = it!=slopes.end();
18554 144909 bool isSlope = is_slope;
18555
18556
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144909 if(isSlope && !wasSlope)
18557 {
18558 static std::vector<word> TMP;
18559 int num_border_combos = cur_region.screen_width*16 * 2 + cur_region.screen_height*11 * 2;
18560 TMP.resize(num_border_combos * 7 * 4);
18561
18562 int tmp_index = id-create_slope_id(SLOPE_STAGE_COMBOS_BORDERING_SCREENS,0,0);
18563 TMP[tmp_index] = cid;
18564 slopes.try_emplace(id, &TMP[tmp_index], nullptr, -1, offx, offy);
18565 }
18566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144909 else if(wasSlope && !isSlope)
18567 {
18568 slopes.erase(it);
18569 }
18570 144909 }
18571
18572 // Load a single column or row from a nearby screen, and load its slopes.
18573 3884 static void handle_slope_combopos_bordering_screen(int initial_screen, int dir)
18574 {
18575 55866 auto [map, screen] = nextscr2(cur_map, initial_screen, dir);
18576
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 171 times.
3884 if (map == -1)
18577 171 return;
18578
18579 3713 int offx = 0;
18580 3713 int offy = 0;
18581
2/2
✓ Branch 0 taken 2800 times.
✓ Branch 1 taken 913 times.
3713 if (dir == up)
18582 913 offy = -16;
18583
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 1938 times.
2800 else if (dir == down)
18584 862 offy = world_h;
18585
2/2
✓ Branch 0 taken 968 times.
✓ Branch 1 taken 970 times.
1938 else if (dir == left)
18586 968 offx = -16;
18587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 else if (dir == right)
18588 970 offx = world_w;
18589
18590
2/2
✓ Branch 0 taken 3713 times.
✓ Branch 1 taken 25991 times.
29704 for (int layer = 0; layer < 7; layer++)
18591 {
18592 51982 auto scr = load_temp_mapscr_and_apply_secrets(map, screen, layer - 1, true, false);
18593
2/2
✓ Branch 0 taken 10824 times.
✓ Branch 1 taken 15167 times.
25991 if (!scr) continue;
18594
18595 10824 int slope_count = layer * (16*2);
18596
18597
4/4
✓ Branch 0 taken 7999 times.
✓ Branch 1 taken 2825 times.
✓ Branch 2 taken 2830 times.
✓ Branch 3 taken 5169 times.
10824 if (dir == left || dir == right)
18598 {
18599 5655 int x = dir == left ? 15 : 0;
18600
2/2
✓ Branch 0 taken 62205 times.
✓ Branch 1 taken 5655 times.
67860 for (int y = 0; y < 11; y++)
18601 {
18602 62205 int pos = y * 16 + x;
18603 62205 int cid = scr->data[pos];
18604 62205 bool is_slope = combobuf[cid].type == cSLOPE;
18605
1/2
✓ Branch 0 taken 62205 times.
✗ Branch 1 not taken.
62205 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx, offy + y*16);
18606 62205 }
18607 5655 }
18608
3/4
✓ Branch 0 taken 2494 times.
✓ Branch 1 taken 2675 times.
✓ Branch 2 taken 2494 times.
✗ Branch 3 not taken.
5169 else if (dir == up || dir == down)
18609 {
18610 5169 int y = dir == up ? 10 : 0;
18611
2/2
✓ Branch 0 taken 82704 times.
✓ Branch 1 taken 5169 times.
87873 for (int x = 0; x < 16; x++)
18612 {
18613 82704 int pos = y * 16 + x;
18614 82704 int cid = scr->data[pos];
18615 82704 bool is_slope = combobuf[cid].type == cSLOPE;
18616
1/2
✓ Branch 0 taken 82704 times.
✗ Branch 1 not taken.
82704 update_slope_combopos_bordering_screen(dir, slope_count++, cid, is_slope, offx + x*16, offy);
18617 82704 }
18618 5169 }
18619
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 15167 times.
✓ Branch 2 taken 10824 times.
25991 }
18620 3884 }
18621
18622 35819 void update_slope_comboposes()
18623 {
18624 14915211 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18625 14879392 update_slope_combopos(rpos_handle);
18626 14879392 });
18627
18628
2/2
✓ Branch 0 taken 34848 times.
✓ Branch 1 taken 971 times.
35819 if (Hero.sideview_mode())
18629 {
18630 1942 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
18631
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 971 times.
4855 for (int dir = up; dir <= right; dir++)
18632 3884 handle_slope_combopos_bordering_screen(scr->screen, dir);
18633 971 });
18634 971 }
18635
18636 35819 update_slopes();
18637 35819 }
18638
18639 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
18640 1384359 void screen_combo_modify_preroutine(const rpos_handle_t& rpos_handle)
18641 {
18642 1384359 delete_fireball_shooter(rpos_handle);
18643 1384359 }
18644
18645 //Placeholder in case we need it.
18646 void screen_ffc_modify_preroutine(const ffc_handle_t& ffc_handle)
18647 {
18648 return;
18649 }
18650
18651 // Everything that must be done after we change a screen's combo to another combo. -L
18652 1384359 void screen_combo_modify_postroutine(const rpos_handle_t& rpos_handle)
18653 {
18654 1384359 rpos_handle.scr->valid |= mVALID;
18655 1384359 activate_fireball_statue(rpos_handle);
18656
18657
2/2
✓ Branch 0 taken 1384265 times.
✓ Branch 1 taken 94 times.
1384359 if(rpos_handle.ctype()==cSPINTILE1)
18658 {
18659 94 awaken_spinning_tile(rpos_handle);
18660 94 }
18661
18662 1384359 update_slope_combopos(rpos_handle);
18663 1384359 }
18664
18665 4500554 void screen_ffc_modify_postroutine(const ffc_handle_t& ffc_handle)
18666 {
18667 4500554 ffcdata* ff = ffc_handle.ffc;
18668 4500554 auto& cmb = ffc_handle.combo();
18669
18670 4500554 auto id = create_slope_id(SLOPE_STAGE_FFCS, ffc_handle.id, -1);
18671 4500554 auto it = slopes.find(id);
18672
18673 4500554 bool wasSlope = it!=slopes.end();
18674
1/2
✓ Branch 0 taken 4500554 times.
✗ Branch 1 not taken.
4500554 bool isSlope = cmb.type == cSLOPE && !(ff->flags&ffc_changer);
18675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500554 if(isSlope && !wasSlope)
18676 {
18677 slopes.try_emplace(id, nullptr, ff, ffc_handle.id);
18678 }
18679
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4500554 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4500554 else if(wasSlope && !isSlope)
18680 {
18681 slopes.erase(it);
18682 }
18683
18684 4500554 ffc_handle.scr->ffcCountMarkDirty();
18685 4500554 }
18686
18687 4414 void screen_combo_modify_pre(int32_t cid)
18688 {
18689 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18690
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18691 {
18692 5195 screen_combo_modify_preroutine(rpos_handle);
18693 5195 }
18694 2808608 });
18695 4414 }
18696 4414 void screen_combo_modify_post(int32_t cid)
18697 {
18698 4414 combo_caches::refresh(cid);
18699
18700 2813022 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
18701
2/2
✓ Branch 0 taken 2803413 times.
✓ Branch 1 taken 5195 times.
2808608 if (rpos_handle.data() == cid)
18702 {
18703 5195 screen_combo_modify_postroutine(rpos_handle);
18704 5195 }
18705 2808608 });
18706
18707 144186 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
18708
2/2
✓ Branch 0 taken 139714 times.
✓ Branch 1 taken 58 times.
139772 if (ffc_handle.data() == cid)
18709 {
18710 58 screen_ffc_modify_postroutine(ffc_handle);
18711 58 }
18712 139772 });
18713 4414 }
18714
18715 94 void awaken_spinning_tile(const rpos_handle_t& rpos_handle)
18716 {
18717 94 int cid = rpos_handle.data();
18718 94 int cset = rpos_handle.cset();
18719 282 auto [x, y] = rpos_handle.xy();
18720
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
282 addenemy(rpos_handle.screen, x, y, (cset<<12)+eSPINTILE1, combobuf[cid].o_tile + zc_max(1,combobuf[cid].frames));
18721 94 }
18722
18723 // It stands for next_side_pos
18724 // moves sle_x and sle_y to the next position
18725 11464 void nsp(bool random)
18726 {
18727
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 8203 times.
11464 if(random)
18728 {
18729
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
18730 {
18731 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
18732 1634 sle_y = (zc_oldrand()%10)*16;
18733 1634 }
18734 else
18735 {
18736 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
18737 1627 sle_x = (zc_oldrand()%15)*16;
18738 }
18739
18740 3261 return;
18741 }
18742
18743
2/2
✓ Branch 0 taken 6168 times.
✓ Branch 1 taken 2035 times.
8203 if(sle_x==0)
18744 {
18745
2/2
✓ Branch 0 taken 1855 times.
✓ Branch 1 taken 180 times.
2035 if(sle_y<160)
18746 1855 sle_y+=16;
18747 else
18748 180 sle_x+=16;
18749 2035 }
18750
2/2
✓ Branch 0 taken 2596 times.
✓ Branch 1 taken 3572 times.
6168 else if(sle_y==160)
18751 {
18752
2/2
✓ Branch 0 taken 2430 times.
✓ Branch 1 taken 166 times.
2596 if(sle_x<240)
18753 2430 sle_x+=16;
18754 else
18755 166 sle_y-=16;
18756 2596 }
18757
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 2020 times.
3572 else if(sle_x==240)
18758 {
18759
2/2
✓ Branch 0 taken 1404 times.
✓ Branch 1 taken 148 times.
1552 if(sle_y>0)
18760 1404 sle_y-=16;
18761 else
18762 148 sle_x-=16;
18763 1552 }
18764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2020 times.
2020 else if(sle_y==0)
18765 {
18766
1/2
✓ Branch 0 taken 2020 times.
✗ Branch 1 not taken.
2020 if(sle_x>0)
18767 2020 sle_x-=16;
18768 else
18769 sle_y+=16;
18770 2020 }
18771 11464 }
18772
18773 // moves sle_x and sle_y to the next available position
18774 // returns the direction the enemy should face
18775 2429 int32_t next_side_pos(int32_t screen, bool random)
18776 {
18777 bool blocked;
18778 2429 int32_t c=0;
18779 25357 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
18780
18781 2429 do
18782 {
18783
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 11333 times.
11464 nsp(c>35 ? false : random);
18784 22928 int x = sle_x + offx;
18785 22928 int y = sle_y + offy;
18786
4/4
✓ Branch 0 taken 2447 times.
✓ Branch 1 taken 9017 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 2428 times.
13892 blocked = _walkflag(x,y,2) || _walkflag(x,y+8,2) ||
18787
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 (combo_class_buf[COMBOTYPE(x,y)].block_enemies ||
18788
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2428 times.
✗ Branch 3 not taken.
2428 MAPFLAG(x,y) == mfNOENEMY || MAPCOMBOFLAG(x,y)==mfNOENEMY ||
18789
2/4
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2428 times.
2428 MAPFLAG(x,y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(x,y)==mfNOGROUNDENEMY ||
18790 2428 iswaterex_z3(MAPCOMBO(x,y), -1, x, y, true));
18791
18792
2/2
✓ Branch 0 taken 11463 times.
✓ Branch 1 taken 1 times.
11464 if(++c>50)
18793 1 return -1;
18794
2/2
✓ Branch 0 taken 9035 times.
✓ Branch 1 taken 2428 times.
11463 }
18795 11463 while(blocked);
18796
18797 2428 int32_t dir=0;
18798
18799
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 736 times.
2428 if(sle_x==0) dir=right;
18800
18801
2/2
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 569 times.
2428 if(sle_y==0) dir=down;
18802
18803
2/2
✓ Branch 0 taken 1720 times.
✓ Branch 1 taken 708 times.
2428 if(sle_x==240) dir=left;
18804
18805
1/2
✓ Branch 0 taken 2428 times.
✗ Branch 1 not taken.
2428 if(sle_y==168) dir=up;
18806
18807 2428 return dir;
18808 2429 }
18809
18810 bool can_side_load(int32_t id)
18811 {
18812 if( ((unsigned)(id&0xFFF)) > MAXGUYS-1 || id <= 0)
18813 {
18814 return false;
18815 }
18816
18817 id = id&0xFFF;
18818
18819 switch(guysbuf[id].family)
18820 {
18821 case eeTEK:
18822 case eeLEV:
18823 case eeAQUA:
18824 case eeDONGO:
18825 case eeMANHAN:
18826 case eeGLEEOK:
18827 case eeDIG:
18828 case eeGHOMA:
18829 case eeLANM:
18830 case eePATRA:
18831 case eeGANON:
18832 case eePROJECTILE:
18833 return false;
18834 break;
18835 }
18836
18837 return true;
18838 }
18839
18840 bool enemy_spawning_has_checked_been_here;
18841 static bool enemy_spawning_has_been_here;
18842
18843 35015 static bool check_if_recently_visited()
18844 {
18845
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 34493 times.
35015 if (enemy_spawning_has_checked_been_here)
18846 522 return enemy_spawning_has_been_here;
18847
18848 34493 int mi = mapind(cur_map, cur_screen);
18849
18850 34493 enemy_spawning_has_been_here = false;
18851
2/2
✓ Branch 0 taken 206958 times.
✓ Branch 1 taken 34493 times.
241451 for (int i = 0; i < 6; i++)
18852
2/2
✓ Branch 0 taken 197377 times.
✓ Branch 1 taken 9581 times.
216539 if (visited[i] == mi)
18853 9581 enemy_spawning_has_been_here = true;
18854
18855
2/2
✓ Branch 0 taken 9581 times.
✓ Branch 1 taken 24912 times.
34493 if (!enemy_spawning_has_been_here)
18856 {
18857 24912 visited[vhead] = mi; //If not, it adds it to the array,
18858 24912 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
18859 24912 }
18860
18861 34493 enemy_spawning_has_checked_been_here = true;
18862 34493 return enemy_spawning_has_been_here;
18863 35015 }
18864
18865 static std::array<bool, MAPSCRS> script_sle;
18866
18867 static int32_t sle_pattern = 0;
18868 static void script_side_load_enemies(mapscr* scr)
18869 {
18870 if (script_sle[scr->screen] || sle_clk) return;
18871
18872 sle_cnt = 0;
18873 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18874 ++sle_cnt;
18875 script_sle[scr->screen] = true;
18876 sle_pattern = scr->pattern;
18877 sle_clk = 0;
18878 }
18879
18880 54516 static void side_load_enemies(mapscr* scr)
18881 {
18882 54516 int screen = scr->screen;
18883
18884
3/4
✓ Branch 0 taken 683 times.
✓ Branch 1 taken 53833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 683 times.
54516 if (sle_clk==0 && !script_sle[scr->screen])
18885 {
18886 683 sle_pattern = scr->pattern;
18887 683 sle_cnt = 0;
18888 683 int32_t guycnt = 0;
18889
18890 683 int mi = mapind(cur_map, screen);
18891 683 bool reload=true;
18892 683 bool unbeatablereload = true;
18893
18894 683 load_default_enemies(scr);
18895
18896 683 bool beenhere = check_if_recently_visited();
18897
4/4
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 480 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 42 times.
683 if (beenhere && game->guys[mi] == 0)
18898 {
18899 42 sle_cnt=0;
18900 42 reload=false;
18901 42 }
18902
18903
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 641 times.
683 if(reload)
18904 {
18905 641 sle_cnt = game->guys[mi];
18906
18907
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 221 times.
641 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
18908 641 || sle_cnt==0)
18909 {
18910
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1272 times.
✓ Branch 2 taken 1054 times.
✓ Branch 3 taken 221 times.
1275 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18911 1054 ++sle_cnt;
18912 221 }
18913
3/4
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 161 times.
✓ Branch 2 taken 480 times.
✗ Branch 3 not taken.
641 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
18914 {
18915 for(int32_t i = 0; i<sle_cnt && scr->enemy[i]>0; i++)
18916 {
18917 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
18918 {
18919 unbeatablereload = false;
18920 }
18921 }
18922 if (unbeatablereload)
18923 {
18924 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18925 {
18926 ++sle_cnt;
18927 }
18928 }
18929 }
18930 641 }
18931
18932
3/4
✓ Branch 0 taken 652 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 652 times.
683 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN))
18933 {
18934 31 sle_cnt = 0;
18935
18936
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 31 times.
139 while(sle_cnt<10 && scr->enemy[sle_cnt]!=0)
18937 108 ++sle_cnt;
18938 31 }
18939
18940
2/2
✓ Branch 0 taken 2446 times.
✓ Branch 1 taken 683 times.
3129 for(int32_t i=0; i<sle_cnt; i++)
18941 2446 ++guycnt;
18942
18943 683 game->guys[mi] = guycnt;
18944 683 }
18945
18946
2/2
✓ Branch 0 taken 52087 times.
✓ Branch 1 taken 2429 times.
54516 if((++sle_clk+8)%24 == 0)
18947 {
18948 2429 int32_t dir = next_side_pos(screen, sle_pattern==pSIDESR);
18949 6819 auto [x, y] = translate_screen_coordinates_to_world(screen, sle_x, sle_y);
18950
18951
6/6
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 2195 times.
✓ Branch 4 taken 233 times.
✓ Branch 5 taken 2195 times.
2429 if(dir==-1 || tooclose(x,y,32))
18952 {
18953 234 return;
18954 }
18955
18956 2195 int32_t enemy_slot=guys.Count();
18957
18958
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2195 times.
2195 while(sle_cnt > 0 && !ok2add(scr, scr->enemy[sle_cnt-1]))
18959 sle_cnt--;
18960
18961
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if(sle_cnt > 0)
18962 {
18963
3/6
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2195 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2195 times.
✗ Branch 5 not taken.
6585 if(addenemy(screen, x,y,scr->enemy[--sle_cnt],0))
18964 {
18965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2195 times.
2195 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
18966 {
18967 2195 guys.spr(enemy_slot)->dir = dir;
18968 2195 }
18969
1/2
✓ Branch 0 taken 2195 times.
✗ Branch 1 not taken.
2195 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
18970 {
18971 if (!FFCore.system_suspend[susptNPCSCRIPTS])
18972 {
18973 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
18974 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
18975 }
18976 }
18977 2195 }
18978 2195 }
18979 2195 }
18980
18981
2/2
✓ Branch 0 taken 53704 times.
✓ Branch 1 taken 578 times.
54282 if(sle_cnt<=0)
18982 {
18983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
578 if (script_sle[screen])
18984 script_sle[screen] = false;
18985 else
18986 {
18987 578 get_screen_state(screen).loaded_enemies = true;
18988 }
18989 578 sle_clk = 0;
18990 578 }
18991 54516 }
18992
18993 1253385 bool is_starting_pos(mapscr* scr, int32_t i, int32_t x, int32_t y, int32_t t)
18994 {
18995
2/2
✓ Branch 0 taken 116390 times.
✓ Branch 1 taken 1136995 times.
1253385 if (!is_in_scrolling_region())
18996
2/4
✓ Branch 0 taken 1136995 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1136995 times.
1136995 if(scr->enemy[i]<1||scr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
18997 {
18998 return false; //never 0, never OoB.
18999 }
19000 // No corner enemies
19001
6/6
✓ Branch 0 taken 1082376 times.
✓ Branch 1 taken 171009 times.
✓ Branch 2 taken 41283 times.
✓ Branch 3 taken 1123659 times.
✓ Branch 4 taken 117940 times.
✓ Branch 5 taken 94352 times.
1253385 if ((x==0 || x==world_w-16) && (y==0 || y==world_h-16))
19002 212292 return false;
19003
19004 //Is a no spawn combo...
19005
4/4
✓ Branch 0 taken 1123647 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1123651 times.
1123659 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19006 16 return false;
19007
19008 // No enemies in dungeon walls
19009
2/2
✓ Branch 0 taken 468562 times.
✓ Branch 1 taken 655089 times.
1123651 if (isdungeon(scr->screen))
19010 {
19011 655089 auto [offx, offy] = translate_screen_coordinates_to_world(scr->screen);
19012
17/18
✓ Branch 0 taken 655089 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 582529 times.
✓ Branch 3 taken 72560 times.
✓ Branch 4 taken 582529 times.
✓ Branch 5 taken 72560 times.
✓ Branch 6 taken 509969 times.
✓ Branch 7 taken 72560 times.
✓ Branch 8 taken 509969 times.
✓ Branch 9 taken 72560 times.
✓ Branch 10 taken 422897 times.
✓ Branch 11 taken 87072 times.
✓ Branch 12 taken 422897 times.
✓ Branch 13 taken 87072 times.
✓ Branch 14 taken 87072 times.
✓ Branch 15 taken 335825 times.
✓ Branch 16 taken 87072 times.
✓ Branch 17 taken 335825 times.
655089 if(isdungeon(scr->screen) && (x<32+offx || x>=224+offx || y<32+offy || y>=144+offy))
19013 319264 return false;
19014 335825 }
19015
19016 // Too close to hero
19017
4/4
✓ Branch 0 taken 77007 times.
✓ Branch 1 taken 727380 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 76906 times.
804387 if(tooclose(x,y,40) && t<11)
19018 76906 return false;
19019
19020 // Can't fly onto it?
19021
4/4
✓ Branch 0 taken 139610 times.
✓ Branch 1 taken 587871 times.
✓ Branch 2 taken 35960 times.
✓ Branch 3 taken 25255 times.
788696 if(isflier(scr->enemy[i])&&
19022
2/2
✓ Branch 0 taken 139220 times.
✓ Branch 1 taken 390 times.
139610 (flyerblocked(x+8,y+8,spw_floater,guysbuf[scr->enemy[i]])||
19023
2/2
✓ Branch 0 taken 61215 times.
✓ Branch 1 taken 78005 times.
139220 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19024 25645 return false;
19025
19026 // Can't jump onto it?
19027 if
19028 (
19029
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 88704 times.
790544 guysbuf[scr->enemy[i]].family==eeTEK
19030
19031
2/2
✓ Branch 0 taken 88722 times.
✓ Branch 1 taken 613114 times.
701836 &&
19032 (
19033
2/2
✓ Branch 0 taken 88715 times.
✓ Branch 1 taken 7 times.
88722 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19034
2/2
✓ Branch 0 taken 88714 times.
✓ Branch 1 taken 1 times.
88715 COMBOTYPE(x+8,y+8)==cNOENEMY||
19035
1/2
✓ Branch 0 taken 88714 times.
✗ Branch 1 not taken.
88714 ispitfall(x+8,y+8)||
19036
2/2
✓ Branch 0 taken 88708 times.
✓ Branch 1 taken 6 times.
88714 MAPFLAG(x+8,y+8)==mfNOENEMY||
19037 88708 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19038 )
19039 )
19040 {
19041 18 return false;
19042 }
19043
19044 // Other off-limit combos
19045
6/6
✓ Branch 0 taken 587849 times.
✓ Branch 1 taken 113969 times.
✓ Branch 2 taken 499145 times.
✓ Branch 3 taken 88704 times.
✓ Branch 4 taken 276410 times.
✓ Branch 5 taken 222735 times.
1200963 if((!isflier(scr->enemy[i])&& guysbuf[scr->enemy[i]].family!=eeTEK &&
19046
2/2
✓ Branch 0 taken 281968 times.
✓ Branch 1 taken 217177 times.
499145 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[scr->enemy[i]]))) &&
19047 499145 guysbuf[scr->enemy[i]].family!=eeZORA)
19048 222735 return false;
19049
19050 // Don't ever generate enemies on these combos!
19051
4/4
✓ Branch 0 taken 478779 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 478785 times.
479083 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19052 310 return false;
19053
19054 //BS Dodongos need at least 2 spaces.
19055
4/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 477746 times.
✓ Branch 2 taken 1014 times.
✓ Branch 3 taken 25 times.
478785 if ((guysbuf[scr->enemy[i]].family==eeDONGO)&&(guysbuf[scr->enemy[i]].attributes[9] == 1))
19056 {
19057
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19 times.
25 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19058
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 ((x>224)||_walkflag(x+16,y+8, 2))&&
19059
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6 ((y<16) ||_walkflag(x, y-8, 2))&&
19060 ((y>144)||_walkflag(x, y+24,2)))
19061 {
19062 return false;
19063 }
19064 19 }
19065
19066 478779 return true;
19067 1147243 }
19068
19069 160492 bool is_ceiling_pattern(int32_t i)
19070 {
19071
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 160472 times.
160492 return (i==pCEILING || i==pCEILINGR);
19072 }
19073
19074 5955 rpos_t placeenemy(mapscr* scr, int32_t i, int32_t offx, int32_t offy)
19075 {
19076 5955 std::vector<rpos_t> freeposcache;
19077
19078
2/2
✓ Branch 0 taken 65505 times.
✓ Branch 1 taken 5955 times.
71460 for(int32_t y=offy; y<offy+176; y+=16)
19079 {
19080
2/2
✓ Branch 0 taken 1048080 times.
✓ Branch 1 taken 65505 times.
1113585 for(int32_t x=offx; x<offx+256; x+=16)
19081 {
19082
3/4
✓ Branch 0 taken 1048080 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✓ Branch 3 taken 627025 times.
1048080 if(is_starting_pos(scr,i,x,y,0))
19083 {
19084
2/4
✓ Branch 0 taken 421055 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 421055 times.
✗ Branch 3 not taken.
421055 freeposcache.push_back(COMBOPOS_REGION(x, y));
19085 421055 }
19086 1048080 }
19087 65505 }
19088
19089
2/2
✓ Branch 0 taken 5944 times.
✓ Branch 1 taken 11 times.
5955 if (!freeposcache.empty())
19090
1/2
✓ Branch 0 taken 5944 times.
✗ Branch 1 not taken.
5944 return freeposcache[zc_oldrand()%freeposcache.size()];
19091
19092 11 return rpos_t::None;
19093 5955 }
19094
19095 81048 void spawnEnemy(mapscr* scr, int& pos, int& clk, int offx, int offy, int& fastguys, int& i, int& guycnt, int& loadcnt)
19096 {
19097 81048 int screen = scr->screen;
19098 81048 int x = 0;
19099 81048 int y = 0;
19100 81048 bool placed=false;
19101 81048 int32_t t=-1;
19102
19103 // First: enemy combo flags
19104
2/2
✓ Branch 0 taken 804493 times.
✓ Branch 1 taken 63679 times.
868172 for(int32_t sy=0; sy<176; sy+=16)
19105 {
19106
2/2
✓ Branch 0 taken 12742722 times.
✓ Branch 1 taken 787124 times.
13529846 for(int32_t sx=0; sx<256; sx+=16)
19107 {
19108 12742722 x = offx + sx;
19109 12742722 y = offy + sy;
19110 12742722 int32_t cflag = MAPFLAG(x, y);
19111 12742722 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19112
19113
2/4
✓ Branch 0 taken 12742722 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12742722 times.
✗ Branch 3 not taken.
12742722 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19114 {
19115 if(!ok2add(scr, scr->enemy[i]))
19116 {
19117 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19118 }
19119 else
19120 {
19121 addenemy_z(screen,x,
19122 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19123 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19124
19125 ++guycnt;
19126
19127 placed=true;
19128 goto placed_enemy;
19129 }
19130 }
19131
19132
4/4
✓ Branch 0 taken 12725304 times.
✓ Branch 1 taken 17418 times.
✓ Branch 2 taken 12725304 times.
✓ Branch 3 taken 17418 times.
12742722 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19133 {
19134
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 17369 times.
17418 if(!ok2add(scr, scr->enemy[i]))
19135 {
19136
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
49 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19137 49 }
19138 else
19139 {
19140 34738 addenemy_z(screen,x,
19141
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17368 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17369 (is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19142
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17368 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
17369 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],-15);
19143
19144 17369 ++guycnt;
19145
19146 17369 placed=true;
19147 17369 goto placed_enemy;
19148 }
19149 49 }
19150 12725353 }
19151 787124 }
19152
19153 // Next: enemy pattern
19154
6/8
✓ Branch 0 taken 4997 times.
✓ Branch 1 taken 58682 times.
✓ Branch 2 taken 57945 times.
✓ Branch 3 taken 5734 times.
✓ Branch 4 taken 57945 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 57945 times.
63679 if((scr->pattern==pRANDOM || scr->pattern==pCEILING) && !(isSideViewGravity()) && ((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS)))
19155 {
19156 57945 do
19157 {
19158
19159 // NES positions
19160 99384 pos%=9;
19161 99384 x=offx+stx[loadside][pos];
19162 99384 y=offy+sty[loadside][pos];
19163 99384 ++pos;
19164 99384 ++t;
19165
2/2
✓ Branch 0 taken 41439 times.
✓ Branch 1 taken 57945 times.
157329 }
19166
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 99163 times.
99384 while((t< 20) && !is_starting_pos(scr,i,x,y,t));
19167 57945 }
19168
19169
4/4
✓ Branch 0 taken 57945 times.
✓ Branch 1 taken 5734 times.
✓ Branch 2 taken 221 times.
✓ Branch 3 taken 57724 times.
63679 if(t<0 || t >= 20) // above enemy pattern failed
19170 {
19171 // Final chance: find a random position anywhere onscreen
19172 5955 rpos_t rand_rpos = placeenemy(scr, i, offx, offy);
19173
19174
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5944 times.
5955 if (rand_rpos != rpos_t::None)
19175 {
19176 5944 std::tie(x, y) = COMBOXY_REGION(rand_rpos);
19177 5944 }
19178 else // All opportunities failed - abort
19179 {
19180 11 return;
19181 }
19182 5944 }
19183
19184 {
19185 63668 int32_t c=0;
19186 63668 c=clk;
19187
19188
2/2
✓ Branch 0 taken 9613 times.
✓ Branch 1 taken 54055 times.
63668 if(!slowguy(scr->enemy[i]))
19189 54055 ++fastguys;
19190
2/2
✓ Branch 0 taken 1586 times.
✓ Branch 1 taken 8027 times.
9613 else if(fastguys>0)
19191 1586 c=-15*(i-fastguys+2);
19192 else
19193 8027 c=-15*(i+1);
19194
19195
4/6
✓ Branch 0 taken 29160 times.
✓ Branch 1 taken 34508 times.
✓ Branch 2 taken 29160 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 29160 times.
63668 if(BSZ&&((scr->enemy[i]>0&&scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19196 {
19197 // Special case for blue leevers
19198
4/4
✓ Branch 0 taken 1894 times.
✓ Branch 1 taken 27266 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 1133 times.
29160 if(guysbuf[scr->enemy[i]].family==eeLEV && guysbuf[scr->enemy[i]].attributes[0] == 1)
19199 761 c=-15*(i+1);
19200 else
19201 28399 c=-15;
19202 29160 }
19203
19204
2/2
✓ Branch 0 taken 62877 times.
✓ Branch 1 taken 791 times.
63668 if(!ok2add(scr, scr->enemy[i]))
19205 {
19206
4/6
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 661 times.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 130 times.
791 if (loadcnt < 10 && scr->enemy[i] > 0 && scr->enemy[i] < MAXGUYS) ++loadcnt;
19207 791 }
19208 else
19209 {
19210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 62877 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
62877 if(((scr->enemy[i]>0||scr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19211 {
19212
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62701 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
125754 addenemy_z(screen,x,(is_ceiling_pattern(scr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19213
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 62701 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 176 times.
62877 (is_ceiling_pattern(scr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,scr->enemy[i],c);
19214
19215 62877 ++guycnt;
19216 62877 }
19217 }
19218
19219 63668 placed=true;
19220 63668 } // if(t < 20)
19221
19222 placed_enemy:
19223
19224 // I don't like this, but it seems to work...
19225 static bool foundCarrier;
19226
19227
2/2
✓ Branch 0 taken 59444 times.
✓ Branch 1 taken 21593 times.
81037 if(i==0)
19228 21593 foundCarrier=false;
19229
19230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81037 times.
81037 if(placed)
19231 {
19232
4/4
✓ Branch 0 taken 21593 times.
✓ Branch 1 taken 59444 times.
✓ Branch 2 taken 21424 times.
✓ Branch 3 taken 169 times.
81037 if(i==0 && scr->flags11&efLEADER)
19233 {
19234 169 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19235
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 7 times.
169 if (e)
19236 {
19237 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19238
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162 if ((e->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER))
19239 {
19240 e = find_guy_nth_for_id(screen, scr->enemy[i], 2, 0xFFF);
19241 }
19242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
162 if (e)
19243 {
19244 162 e->leader = true;
19245 162 }
19246 162 }
19247 169 }
19248
19249 81037 ScreenItemState item_state = get_screen_state(screen).item_state;
19250
5/6
✓ Branch 0 taken 80795 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 80795 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77 times.
✓ Branch 5 taken 80718 times.
81037 if (!foundCarrier && (item_state == ScreenItemState::CarriedByEnemy || item_state == ScreenItemState::MustGiveToEnemy))
19251 {
19252 77 enemy* e = find_guy_first_for_id(screen, scr->enemy[i], 0xFFF);
19253
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if (e && (e->flags&guy_doesnt_count)==0)
19254 {
19255 77 e->itemguy = true;
19256 77 foundCarrier=true;
19257 77 }
19258 77 }
19259 81037 }
19260 81048 }
19261
19262 // returns index of first sprite with matching id, -1 if none found
19263 246 enemy* find_guy_first_for_id(int screen, int id, int mask)
19264 {
19265 246 int count = guys.Count();
19266
2/2
✓ Branch 0 taken 366 times.
✓ Branch 1 taken 7 times.
373 for (int32_t i=0; i<count; i++)
19267 {
19268 366 enemy* e = (enemy*)guys.spr(i);
19269
4/4
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 239 times.
✓ Branch 3 taken 79 times.
366 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19270 {
19271 239 return e;
19272 }
19273 127 }
19274
19275 7 return nullptr;
19276 246 }
19277
19278 enemy* find_guy_nth_for_id(int screen, int id, int n, int mask)
19279 {
19280 int count = guys.Count();
19281 for(int32_t i=0; i<count; i++)
19282 {
19283 enemy* e = (enemy*)guys.spr(i);
19284 if (e->screen_spawned == screen && (e->id&mask) == (id&mask))
19285 {
19286 if (n > 1) --n;
19287 else return e;
19288 }
19289 }
19290 return nullptr;
19291 }
19292
19293 bool scriptloadenemies(int screen)
19294 {
19295 if (sle_clk || script_sle[screen]) return false;
19296
19297 mapscr* scr = get_scr(screen);
19298 if(scr->pattern==pNOSPAWN) return false;
19299
19300 if(scr->pattern==pSIDES || scr->pattern==pSIDESR)
19301 {
19302 script_side_load_enemies(scr);
19303 return true;
19304 }
19305
19306 auto [x, y] = translate_screen_coordinates_to_world(screen);
19307 int32_t pos=zc_oldrand()%9;
19308 int32_t clk=-15,fastguys=0;
19309 int32_t i=0,guycnt=0;
19310 int32_t loadcnt = 10;
19311
19312 for(; i<loadcnt && scr->enemy[i]>0; i++)
19313 {
19314 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19315 spawnEnemy(scr, pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19316 if (guys.Count() > preguycount)
19317 {
19318 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19319 {
19320 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19321 {
19322 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19323 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19324 }
19325 }
19326 }
19327 --clk;
19328 }
19329 return true;
19330 }
19331
19332 14246257 void loadenemies()
19333 {
19334 28872672 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
19335 14626415 int screen = scr->screen;
19336 14626415 auto& state = get_screen_state(screen);
19337
2/2
✓ Branch 0 taken 14212220 times.
✓ Branch 1 taken 414195 times.
14626415 if (state.loaded_enemies)
19338 14212220 return;
19339
19340 // dungeon basements
19341 static byte dngn_enemy_x[4] = {32,96,144,208};
19342
2/2
✓ Branch 0 taken 147965 times.
✓ Branch 1 taken 266230 times.
414195 if (cur_screen>=128)
19343 {
19344
2/2
✓ Branch 0 taken 147490 times.
✓ Branch 1 taken 475 times.
147965 if(DMaps[cur_dmap].flags&dmfCAVES) return;
19345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if ( DMaps[cur_dmap].flags&dmfNEWCELLARENEMIES )
19346 {
19347 for(int32_t i=0; i<10; i++)
19348 {
19349 if ( scr->enemy[i] )
19350 {
19351 int32_t preguycount = guys.Count();
19352 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i],-14-i);
19353 if (guys.Count() > preguycount)
19354 {
19355 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19356 {
19357 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19358 {
19359 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19360 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19361 }
19362 }
19363 }
19364 }
19365 }
19366 }
19367 else
19368 {
19369
2/2
✓ Branch 0 taken 1900 times.
✓ Branch 1 taken 475 times.
2375 for(int32_t i=0; i<4; i++)
19370 {
19371 1900 int32_t preguycount = guys.Count();
19372
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 856 times.
1900 addenemy(screen,dngn_enemy_x[i],96,scr->enemy[i]?scr->enemy[i]:(int32_t)eKEESE1,-14-i);
19373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1900 times.
1900 if (guys.Count() > preguycount)
19374 {
19375
2/2
✓ Branch 0 taken 1896 times.
✓ Branch 1 taken 4 times.
1900 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19376 {
19377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19378 {
19379 4 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19380 4 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19381 4 }
19382 4 }
19383 1900 }
19384 1900 }
19385 }
19386
19387 475 state.loaded_enemies = true;
19388 475 return;
19389 }
19390
19391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 266230 times.
266230 if (scr->pattern == pNOSPAWN)
19392 return;
19393
19394 // TODO: configure when screen enemies spawn.
19395
2/2
✓ Branch 0 taken 88938 times.
✓ Branch 1 taken 177292 times.
266230 if (!viewport.intersects_with(region_scr_x*256, region_scr_y*176, 256, 176))
19396 177292 return;
19397
19398
4/4
✓ Branch 0 taken 50491 times.
✓ Branch 1 taken 38447 times.
✓ Branch 2 taken 16069 times.
✓ Branch 3 taken 34422 times.
88938 if (scr->pattern==pSIDES || scr->pattern==pSIDESR)
19399 {
19400 54516 side_load_enemies(scr);
19401 54516 return;
19402 }
19403
19404 34422 state.loaded_enemies = true;
19405
19406 // check if it's the dungeon boss and it has been beaten before
19407
4/4
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 34064 times.
✓ Branch 2 taken 268 times.
✓ Branch 3 taken 90 times.
34422 if (scr->flags11&efBOSS && game->lvlitems[dlevel]&liBOSS)
19408 90 return;
19409
19410 34332 int32_t loadcnt = 10;
19411 34332 int16_t mi = mapind(cur_map, screen);
19412 34332 bool beenhere = check_if_recently_visited();
19413
19414 //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
19415 34332 bool reload = true;
19416
4/4
✓ Branch 0 taken 9724 times.
✓ Branch 1 taken 24608 times.
✓ Branch 2 taken 4708 times.
✓ Branch 3 taken 5016 times.
34332 if (beenhere && game->guys[mi] == 0) //Then, if you have been here, and the number of enemies left on the screen is 0,
19417 {
19418 5016 loadcnt = 0; //It will tell it not to load any enemies,
19419 5016 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
19420 5016 }
19421
19422 34332 bool unbeatablereload = true;
19423
2/2
✓ Branch 0 taken 5016 times.
✓ Branch 1 taken 29316 times.
34332 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
19424 {
19425 29316 loadcnt = game->guys[mi]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
19426
19427
2/4
✓ Branch 0 taken 10283 times.
✓ Branch 1 taken 19033 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29316 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
19428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10283 times.
10283 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
19429 19033 loadcnt = 10; //That means all enemies need to be respawned.
19430
3/4
✓ Branch 0 taken 24608 times.
✓ Branch 1 taken 4708 times.
✓ Branch 2 taken 24608 times.
✗ Branch 3 not taken.
29316 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19431 {
19432 for(int32_t i = 0; i<loadcnt && scr->enemy[i]>0; i++)
19433 {
19434 if (!(guysbuf[scr->enemy[i]].flags & guy_doesnt_count))
19435 {
19436 unbeatablereload = false;
19437 }
19438 }
19439 if (unbeatablereload)
19440 {
19441 loadcnt = 10;
19442 }
19443 }
19444 29316 }
19445
19446
4/4
✓ Branch 0 taken 32912 times.
✓ Branch 1 taken 1420 times.
✓ Branch 2 taken 193 times.
✓ Branch 3 taken 32719 times.
34332 if((get_qr(qr_ALWAYSRET)) || (scr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
19447 1613 loadcnt = 10; //All enemies also need to be respawned.
19448
19449 // do enemies that are always loaded
19450 34332 load_default_enemies(scr);
19451 34332 activate_fireball_statues(scr);
19452
19453 34332 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
19454 34332 int32_t clk=-15,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
19455 34332 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
19456
4/4
✓ Branch 0 taken 15158 times.
✓ Branch 1 taken 100222 times.
✓ Branch 2 taken 81048 times.
✓ Branch 3 taken 34332 times.
115380 for(; i<loadcnt && scr->enemy[i]>0; i++)
19457 {
19458 81048 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19459 81048 spawnEnemy(scr, pos, clk, region_scr_x*256, region_scr_y*176, fastguys, i, guycnt, loadcnt);
19460
2/2
✓ Branch 0 taken 802 times.
✓ Branch 1 taken 80246 times.
81048 if (guys.Count() > preguycount)
19461 {
19462
2/2
✓ Branch 0 taken 77892 times.
✓ Branch 1 taken 2354 times.
80246 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19463 {
19464
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2350 times.
2354 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19465 {
19466 2350 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19467 2350 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19468 2350 }
19469 2354 }
19470 80246 }
19471
19472 81048 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
19473 81048 }
19474
19475 34332 game->guys[mi] = guycnt;
19476 14626415 });
19477 14246257 }
19478
19479 233 void moneysign()
19480 {
19481 466 auto [dx, dy] = translate_screen_coordinates_to_world(cur_screen);
19482 466 additem(dx+48,dy+108,iRupy,ipDUMMY);
19483 233 set_clip_state(pricesdisplaybuf, 0);
19484 233 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
19485 233 }
19486
19487 3302 void putprices(bool sign)
19488 {
19489
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 3270 times.
3302 if(fadeclk > 0) return;
19490
19491 3270 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
19492 3270 int32_t step=32;
19493 3270 int32_t x=80;
19494
19495
2/2
✓ Branch 0 taken 281 times.
✓ Branch 1 taken 2989 times.
3270 if(prices[2]==0)
19496 {
19497 2989 step<<=1;
19498
19499
2/2
✓ Branch 0 taken 2957 times.
✓ Branch 1 taken 32 times.
2989 if(prices[1]==0)
19500 {
19501 2957 x=112;
19502 2957 }
19503 2989 }
19504
19505
2/2
✓ Branch 0 taken 3270 times.
✓ Branch 1 taken 9810 times.
13080 for(int32_t i=0; i<3; i++)
19506 {
19507 // Kind of stupid, but it works: 100000 is used to indicate that an item
19508 // has a price of zero rather than there being no item.
19509 // 100000 isn't a valid price, so this doesn't cause problems.
19510
3/4
✓ Branch 0 taken 1039 times.
✓ Branch 1 taken 8771 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1039 times.
9810 if(prices[i]!=0 && prices[i]<100000)
19511 {
19512 char buf[8];
19513 1039 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
19514
19515 1039 int32_t l=(int32_t)strlen(buf);
19516 1039 set_clip_state(pricesdisplaybuf, 0);
19517
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 1012 times.
1039 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
19518 1039 }
19519
19520 9810 x+=step;
19521 9810 }
19522 3302 }
19523
19524 // Setting up special rooms
19525 // Also called when the Letter is used successfully.
19526 1208 void setupscreen()
19527 {
19528 1208 boughtsomething=false;
19529
19530 // Either the origin screen, or if in a 0x80 room the screen player came from.
19531
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 794 times.
1208 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : origin_scr;
19532 1208 mapscr* scr = origin_scr;
19533
19534 1208 word str=base_scr->str;
19535
19536 2260 auto [dx, dy] = translate_screen_coordinates_to_world(scr->screen);
19537
19538 // Prices are already set to 0 in dowarp()
19539
14/15
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 689 times.
✓ Branch 2 taken 162 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 11 times.
✓ Branch 6 taken 13 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 17 times.
✓ Branch 10 taken 32 times.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 14 times.
1208 switch(base_scr->room)
19540 {
19541 case rSP_ITEM: // special item
19542 324 additem(dx+120,dy+89,base_scr->catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
19543 162 break;
19544
19545 case rINFO: // pay for info
19546 {
19547 28 int32_t count = 0;
19548 28 int32_t base = 88;
19549 28 int32_t step = 5;
19550
19551 28 moneysign();
19552
19553
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 84 times.
112 for(int32_t i=0; i<3; i++)
19554 {
19555
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(QMisc.info[base_scr->catchall].str[i])
19556 {
19557 84 ++count;
19558 84 }
19559 else
19560 break;
19561 84 }
19562
19563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(count)
19564 {
19565
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==1)
19566 {
19567 base = 88+32;
19568 }
19569
19570
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(count==2)
19571 {
19572 step = 6;
19573 }
19574
19575
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 28 times.
112 for(int32_t i=0; i < count; i++)
19576 {
19577 84 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
19578 84 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19579 84 prices[i] = -(QMisc.info[base_scr->catchall].price[i]);
19580
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 if(prices[i]==0)
19581 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19582 84 int32_t itemid = current_item_id(itype_wealthmedal);
19583
19584
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
84 if(itemid>=0 && prices[i]!=100000)
19585 {
19586 if(itemsbuf[itemid].flags & item_flag1)
19587 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19588 else
19589 prices[i]-=itemsbuf[itemid].misc1;
19590 prices[i]=vbound(prices[i], -99999, 0);
19591 if(prices[i]==0)
19592 prices[i]=100000;
19593 }
19594
19595
2/6
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 84 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
84 if((QMisc.info[base_scr->catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
19596 prices[i]=-1;
19597 84 }
19598 28 }
19599
19600 28 break;
19601 }
19602
19603 case rMONEY: // secret money
19604 88 additem(dx+120,dy+89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
19605 44 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19606 44 break;
19607
19608 case rGAMBLE: // gambling
19609 11 prices[0]=prices[1]=prices[2]=-10;
19610 11 moneysign();
19611 22 additem(dx+88,dy+89,iRupy,ipMONEY+ipDUMMY);
19612 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19613 22 additem(dx+120,dy+89,iRupy,ipMONEY+ipDUMMY);
19614 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19615 22 additem(dx+152,dy+89,iRupy,ipMONEY+ipDUMMY);
19616 11 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
19617 11 break;
19618
19619 case rREPAIR: // door repair
19620
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
19621 // }
19622 13 repaircharge=base_scr->catchall;
19623 13 break;
19624
19625 case rMUPGRADE: // upgrade magic
19626 2 adjustmagic=true;
19627 2 break;
19628
19629 case rLEARNSLASH: // learn slash attack
19630 2 learnslash=true;
19631 2 break;
19632
19633 case rRP_HC: // heart container or red potion
19634 34 additem(dx+88,dy+89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
19635 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19636 34 additem(dx+152,dy+89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
19637 17 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19638 17 break;
19639
19640 case rP_SHOP: // potion shop
19641
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
19642 {
19643 12 str=0;
19644 12 break;
19645 }
19646
19647 [[fallthrough]];
19648 case rTAKEONE: // take one
19649 case rSHOP: // shop
19650 {
19651 194 int32_t count = 0;
19652 194 int32_t base = 88;
19653 194 int32_t step = 5;
19654
19655
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 193 times.
194 if(base_scr->room != rTAKEONE)
19656 193 moneysign();
19657
19658 //count and align the stuff
19659
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 560 times.
717 for(int32_t i=0; i<3; ++i)
19660 {
19661
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 37 times.
560 if(QMisc.shop[base_scr->catchall].hasitem[count] != 0)
19662 {
19663 523 ++count;
19664 523 }
19665 else
19666 {
19667 37 break;
19668 }
19669 523 }
19670
19671
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 22 times.
194 if(count==1)
19672 {
19673 22 base = 88+32;
19674 22 }
19675
19676
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 15 times.
194 if(count==2)
19677 {
19678 15 step = 6;
19679 15 }
19680
19681
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 194 times.
717 for(int32_t i=0; i<count; i++)
19682 {
19683 1046 additem(dx+(i<<step)+base, dy+89, QMisc.shop[base_scr->catchall].item[i], ipHOLDUP+ipFADE+(base_scr->room == rTAKEONE ? ipONETIME2 : ipCHECK));
19684 523 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
19685
19686
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 521 times.
523 if(base_scr->room != rTAKEONE)
19687 {
19688 521 prices[i] = QMisc.shop[base_scr->catchall].price[i];
19689
1/2
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
521 if(prices[i]==0)
19690 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19691 521 int32_t itemid = current_item_id(itype_wealthmedal);
19692
19693
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
521 if(itemid>=0 && prices[i]!=100000)
19694 {
19695
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(itemsbuf[itemid].flags & item_flag1)
19696 9 prices[i]=((prices[i]*itemsbuf[itemid].misc1) / 100);
19697 else
19698 prices[i]+=itemsbuf[itemid].misc1;
19699 9 prices[i]=vbound(prices[i], 0, 99999);
19700
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(prices[i]==0)
19701 prices[i]=100000;
19702 9 }
19703
19704
2/4
✓ Branch 0 taken 521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 521 times.
✗ Branch 3 not taken.
521 if((QMisc.shop[base_scr->catchall].price[i])>1 && prices[i]<1)
19705 prices[i]=1;
19706 521 }
19707 523 }
19708
19709 194 break;
19710 }
19711 case rBOTTLESHOP: // bottle shop
19712 {
19713 1 int32_t count = 0;
19714 1 int32_t base = 88;
19715 1 int32_t step = 5;
19716
19717 1 moneysign();
19718 1 bottleshoptype const& bst = QMisc.bottle_shop_types[base_scr->catchall];
19719 //count and align the stuff
19720
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
4 for(int32_t i=0; i<3; ++i)
19721 {
19722
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(bst.fill[count] != 0)
19723 {
19724 3 ++count;
19725 3 }
19726 else
19727 {
19728 break;
19729 }
19730 3 }
19731
19732
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==1)
19733 {
19734 base = 88+32;
19735 }
19736
19737
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(count==2)
19738 {
19739 step = 6;
19740 }
19741
19742
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
4 for(int32_t i=0; i<count; i++)
19743 {
19744 6 adddummyitem(dx+(i<<step)+base, dy+89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
19745 //{ Setup dummy item
19746 3 item* curItem = ((item*)items.spr(items.Count()-1));
19747 3 curItem->PriceIndex = i;
19748 3 newcombo const& cmb = combobuf[bst.comb[i]];
19749
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(cmb.animflags & AF_EDITOR_ONLY)
19750 {
19751 curItem->yofs = -32768;
19752 }
19753 3 curItem->o_tile = cmb.o_tile;
19754 3 curItem->o_cset = bst.cset[i];
19755 3 curItem->cs = curItem->o_cset;
19756 3 curItem->tile = cmb.o_tile;
19757 3 curItem->o_speed = cmb.speed;
19758 3 curItem->o_delay = 0;
19759 3 curItem->frames = cmb.frames;
19760 3 curItem->flip = cmb.flip;
19761 3 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
19762 3 curItem->pstring = 0;
19763 3 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
19764 3 curItem->flash = false;
19765 3 curItem->twohand = false;
19766 3 curItem->anim = true;
19767 3 curItem->hit_width=1;
19768 3 curItem->hyofs=4;
19769 3 curItem->hit_height=12;
19770 3 curItem->script=0;
19771 3 curItem->txsz=1;
19772 3 curItem->tysz=1;
19773 //}
19774
19775 3 prices[i] = bst.price[i];
19776
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(prices[i]==0)
19777 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
19778 3 int32_t itemid = current_item_id(itype_wealthmedal);
19779
19780
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if(itemid>=0 && prices[i]!=100000)
19781 {
19782 if(itemsbuf[itemid].flags & item_flag1)
19783 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
19784 else
19785 prices[i]+=itemsbuf[itemid].misc1;
19786 prices[i]=vbound(prices[i], 0, 99999);
19787 if(prices[i]==0)
19788 prices[i]=100000;
19789 }
19790
19791
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
3 if((bst.price[i])>1 && prices[i]<1)
19792 prices[i]=1;
19793 3 }
19794
19795 1 break;
19796 }
19797
19798 case rBOMBS: // more bombs
19799 38 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19800 19 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19801 19 prices[0]=-base_scr->catchall;
19802 19 break;
19803
19804 case rARROWS: // more arrows
19805 additem(dx+120,dy+89,iRupy,ipDUMMY+ipMONEY);
19806 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19807 prices[0]=-base_scr->catchall;
19808 break;
19809
19810 case rSWINDLE: // leave heart container or money
19811 28 additem(dx+88,dy+89,iHeartC,ipDUMMY+ipMONEY);
19812 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
19813 14 prices[0]=-1;
19814 28 additem(dx+152,dy+89,iRupy,ipDUMMY+ipMONEY);
19815 14 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
19816 14 prices[1]=-base_scr->catchall;
19817 14 break;
19818
19819 }
19820
19821
3/4
✓ Branch 0 taken 1189 times.
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1189 times.
1208 if(base_scr->room == rBOMBS || base_scr->room == rARROWS)
19822 {
19823 19 int32_t i = (base_scr->room == rSWINDLE ? 1 : 0);
19824 19 int32_t itemid = current_item_id(itype_wealthmedal);
19825
19826
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemid >= 0)
19827 {
19828 if(itemsbuf[itemid].flags & item_flag1)
19829 prices[i]*=(itemsbuf[itemid].misc1 /100.0);
19830 else
19831 prices[i]+=itemsbuf[itemid].misc1;
19832 }
19833
19834
2/4
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
19 if(base_scr->catchall>1 && prices[i]>-1)
19835 prices[i]=-1;
19836 19 }
19837
19838 1208 putprices(false);
19839
19840
2/2
✓ Branch 0 taken 1149 times.
✓ Branch 1 taken 59 times.
1208 if(str)
19841 {
19842 1149 donewmsg(base_scr, str);
19843 1149 }
19844 else
19845 {
19846 59 Hero.unfreeze();
19847 }
19848 1208 }
19849
19850 enum
19851 {
19852 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
19853 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
19854
19855 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
19856
19857 MNU_DATA_MAX
19858 };
19859 struct menu_choice
19860 {
19861 int32_t x, y;
19862 int32_t pos;
19863 int32_t upos, dpos, lpos, rpos;
19864 18 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
19865 18 {}
19866 18 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
19867 int32_t dpos, int32_t lpos, int32_t rpos)
19868 18 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
19869 18 {}
19870 };
19871 static int32_t msg_menu_data[MNU_DATA_MAX];
19872 static bool do_run_menu = false;
19873 bool do_end_str = false;
19874 static bool wait_advance = false;
19875 411 static std::map<int32_t, menu_choice> menu_options;
19876 43834 void clr_msg_data()
19877 {
19878 43834 do_end_str = false;
19879 43834 wait_advance = false;
19880 43834 do_run_menu = false;
19881 43834 menu_options.clear();
19882 43834 memset(msg_menu_data, 0, sizeof(msg_menu_data));
19883 43834 }
19884
19885 static char namebuf[9] = {0};
19886 static char* nameptr = NULL;
19887 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
19888 2036 bool runMenuCursor()
19889 {
19890 2036 clear_bitmap(msg_menu_bmp_buf);
19891
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(!menu_options.size())
19892 {
19893 msg_menu_data[MNU_CHOSEN] = 0;
19894 return true; //end menu
19895 }
19896 2036 int32_t pos = msg_menu_data[MNU_CHOSEN];
19897 //If the cursor is at an invalid pos, find the first pos >= 0...
19898
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19899 {
19900 pos = 0;
19901 while(menu_options.find(pos) == menu_options.end())
19902 ++pos;
19903 }
19904 2036 menu_choice* ch = &menu_options[pos];
19905
19906 2036 bool pressed = true;
19907
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2032 times.
2036 if(rUp()) pos = ch->upos;
19908
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2030 times.
2032 else if(rDown()) pos = ch->dpos;
19909
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2021 times.
2030 else if(rLeft()) pos = ch->lpos;
19910
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 2010 times.
2021 else if(rRight()) pos = ch->rpos;
19911 2010 else pressed = false;
19912
19913
2/2
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
2036 if(pressed)
19914 26 msg_menu_data[MNU_TIMER] = 1;
19915
19916 2036 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
19917 2036 bool held = false;
19918
2/2
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 90 times.
2036 if(hold_input)
19919 {
19920 90 held = true;
19921
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 89 times.
90 if(Up()) pos = ch->upos;
19922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Down()) pos = ch->dpos;
19923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Left()) pos = ch->lpos;
19924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(Right()) pos = ch->rpos;
19925 89 else held = false;
19926 90 }
19927 //If the cursor is at an invalid pos, find the first pos >= 0...
19928
1/2
✓ Branch 0 taken 2036 times.
✗ Branch 1 not taken.
2036 if(menu_options.find(pos) == menu_options.end())
19929 {
19930 pos = 0;
19931 while(menu_options.find(pos) == menu_options.end())
19932 ++pos;
19933 }
19934
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2009 times.
✓ Branch 3 taken 27 times.
2036 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
19935 27 sfx(MsgStrings[msgstr].sfx);
19936
19937 2036 ch = &menu_options[pos];
19938 4072 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
19939 2036 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
19940 2036 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
19941 2036 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
19942
19943 2036 msg_menu_data[MNU_CHOSEN] = pos;
19944
19945
2/2
✓ Branch 0 taken 1433 times.
✓ Branch 1 taken 603 times.
2036 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
19946 {
19947 603 rAbtn(); //Eat
19948
2/2
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 5 times.
603 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
19949 603 }
19950
19951
4/4
✓ Branch 0 taken 2010 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2009 times.
2036 bool ret = (pressed || held) ? false : rAbtn();
19952 //Eat inputs
19953 2036 rUp(); rDown(); rLeft(); rRight(); rAbtn();
19954
19955
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 5 times.
2036 if(ret)
19956 5 menu_options.clear();
19957
19958 2036 return ret;
19959 //false if pos changed this frame; no confirming while moving the cursor!
19960 2036 }
19961
19962 839532 bool bottom_margin_clip()
19963 {
19964 891586 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
19965
2/2
✓ Branch 0 taken 787478 times.
✓ Branch 1 taken 52054 times.
839532 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
19966 }
19967
19968 void update_msgstr();
19969
19970 3293 static bool parsemsgcode(const StringCommand& command)
19971 {
19972 3293 auto& args = command.args;
19973 3293 int last_arg = 0;
19974
19975
18/38
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1280 times.
✓ Branch 3 taken 1644 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 56 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 11 times.
✓ Branch 14 taken 22 times.
✓ Branch 15 taken 7 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 122 times.
✓ Branch 24 taken 28 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 5 times.
✓ Branch 29 taken 18 times.
✓ Branch 30 taken 5 times.
✓ Branch 31 taken 7 times.
✓ Branch 32 taken 3 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
3293 switch (command.code)
19976 {
19977 case MSGC_NEWLINE:
19978 {
19979 1280 ssc_tile_hei = ssc_tile_hei_buf;
19980
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 2 times.
1280 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
19981 1280 ssc_tile_hei_buf = -1;
19982 1280 cursor_y += thei + MsgStrings[msgstr].vspace;
19983 1280 cursor_x=msg_margins[left];
19984 1280 return true;
19985 }
19986
19987 case MSGC_COLOUR:
19988 {
19989 1644 int32_t cset = args[0];
19990 1644 msgcolour = CSET(cset)+(args[1]);
19991 1644 return true;
19992 }
19993
19994 case MSGC_SHDCOLOR:
19995 {
19996 int32_t cset = args[0];
19997 msg_shdcol = CSET(cset)+args[1];
19998 return true;
19999 }
20000 case MSGC_SHDTYPE:
20001 {
20002 msg_shdtype = args[0];
20003 return true;
20004 }
20005
20006 case MSGC_SPEED:
20007 {
20008 56 msgspeed=args[0];
20009 56 return true;
20010 }
20011
20012 case MSGC_CTRUP:
20013 {
20014 int32_t a1 = args[0];
20015 int32_t a2 = args[1];
20016 game->change_counter(a2, a1);
20017 return true;
20018 }
20019
20020 case MSGC_CTRDN:
20021 {
20022 5 int32_t a1 = args[0];
20023 5 int32_t a2 = args[1];
20024 5 game->change_counter(-a2, a1);
20025 5 return true;
20026 }
20027
20028 case MSGC_CTRSET:
20029 {
20030 7 int32_t a1 = args[0];
20031 7 int32_t a2 = args[1];
20032 7 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20033 7 return true;
20034 }
20035
20036 case MSGC_CTRUPPC:
20037 case MSGC_CTRDNPC:
20038 case MSGC_CTRSETPC:
20039 {
20040 2 int32_t counter = args[0];
20041 2 int32_t amount = args[1];
20042 2 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20043
20044
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(command.code==MSGC_CTRDNPC)
20045 amount*=-1;
20046
20047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(command.code==MSGC_CTRSETPC)
20048 game->set_counter(amount, counter);
20049 else
20050 2 game->change_counter(amount, counter);
20051
20052 2 return true;
20053 }
20054
20055 case MSGC_GIVEITEM:
20056 {
20057 70 int32_t itemID = args[0];
20058
20059 70 getitem(itemID, true);
20060
2/4
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
70 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20061 {
20062 70 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20063 70 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&item_passive_script) > 0;
20064 70 }
20065 70 return true;
20066 }
20067
20068
20069 case MSGC_WARP:
20070 {
20071 int32_t dmap = args[0];
20072 int32_t scrn = args[1];
20073 int32_t dx = args[2];
20074 int32_t dy = args[3];
20075 int32_t wfx = args[4];
20076 int32_t sfx = args[5];
20077 if(dx >= MAX_SCC_ARG) dx = -1;
20078 if(dy >= MAX_SCC_ARG) dy = -1;
20079 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, 0, 0);
20080 do_end_str = true;
20081 return true;
20082 }
20083
20084 case MSGC_SETSCREEND:
20085 {
20086 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20087 int32_t screen = args[1];
20088 int32_t reg = args[2];
20089 int32_t val = args[3];
20090 FFCore.set_screen_d(screen + dmap, reg, val);
20091 return true;
20092 }
20093 case MSGC_TAKEITEM:
20094 {
20095 11 int32_t itemID = args[0];
20096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if ( FFCore.doscript(ScriptType::Item, itemID) )
20097 {
20098 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20099 }
20100 11 takeitem(itemID);
20101
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_bwpn == itemID )
20102 {
20103 game->forced_bwpn = -1;
20104 } //not else if! -Z
20105
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_awpn == itemID )
20106 {
20107 game->forced_awpn = -1;
20108 }
20109
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_xwpn == itemID )
20110 {
20111 game->forced_xwpn = -1;
20112 } //not else if! -Z
20113
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if ( game->forced_ywpn == itemID )
20114 {
20115 game->forced_ywpn = -1;
20116 }
20117 11 verifyBothWeapons();
20118 11 return true;
20119 }
20120
20121 case MSGC_SFX:
20122 {
20123 22 sfx(args[0],128);
20124 22 return true;
20125 }
20126
20127 case MSGC_MIDI:
20128 {
20129 7 int32_t music = args[0];
20130
20131
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
7 if(music==0)
20132 1 music_stop();
20133 else
20134 6 jukebox(music+(ZC_MIDI_COUNT-1));
20135
20136 7 return true;
20137 }
20138
20139 case MSGC_FONT:
20140 {
20141 int fontid = args[0];
20142 int oh = text_height(msgfont);
20143 msgfont = get_zc_font(fontid);
20144 int nh = text_height(msgfont);
20145 int mh = std::max(oh,nh);
20146 if(mh > ssc_tile_hei_buf)
20147 ssc_tile_hei_buf = mh;
20148 return true;
20149 }
20150 case MSGC_RUN_FRZ_GENSCR:
20151 {
20152 word scr_id = args[0];
20153 bool force_redraw = args[1]!=0;
20154 if(force_redraw)
20155 {
20156 update_msgstr();
20157 draw_screen();
20158 }
20159 FFCore.runGenericFrozenEngine(scr_id);
20160 return true;
20161 }
20162 case MSGC_DRAWTILE:
20163 {
20164 int32_t tl = args[0];
20165 int32_t cs = args[1];
20166 int32_t t_wid = args[2];
20167 int32_t t_hei = args[3];
20168 int32_t fl = args[4];
20169
20170 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20171 {
20172 ssc_tile_hei = ssc_tile_hei_buf;
20173 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20174 ssc_tile_hei_buf = -1;
20175 cursor_y += thei + MsgStrings[msgstr].vspace;
20176 if(bottom_margin_clip()) return true;
20177 cursor_x=msg_margins[left];
20178 }
20179
20180 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20181 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20182 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20183 return true;
20184 }
20185
20186 case MSGC_GOTOIFRAND:
20187 {
20188 1 int32_t odds = args[0];
20189
20190 1 last_arg = 1;
20191
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!odds || !(zc_oldrand()%odds))
20192 1 goto switched;
20193
20194 return true;
20195 }
20196
20197 case MSGC_GOTOIFGLOBAL:
20198 {
20199 int32_t arg = args[0];
20200 int32_t d = zc_min(7,arg);
20201 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20202 arg = args[1];
20203
20204 if(game->screen_d[s][d] >= arg)
20205 {
20206 last_arg = 2;
20207 goto switched;
20208 }
20209
20210 return true;
20211 }
20212
20213 case MSGC_CHANGEPORTRAIT:
20214 {
20215 return true; //not implemented
20216 }
20217
20218 case MSGC_GOTOIFCREEND:
20219 {
20220 int32_t dmap = (args[0]<<7); //dmap and screen may be transposed here.
20221 int32_t screen = args[1];
20222 int32_t reg = args[2];
20223 int32_t val = args[3];
20224 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20225 {
20226 last_arg = 4;
20227 goto switched;
20228 }
20229 return true;
20230 }
20231
20232 case MSGC_GOTOIF:
20233 {
20234 122 int32_t it = args[0];
20235
20236
3/4
✓ Branch 0 taken 122 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 35 times.
122 if(unsigned(it)<MAXITEMS && game->item[it])
20237 {
20238 35 last_arg = 1;
20239 35 goto switched;
20240 }
20241
20242 87 return true;
20243 }
20244
20245 case MSGC_GOTOIFCTR:
20246 {
20247
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(game->get_counter(args[0]) >= args[1])
20248 {
20249 14 last_arg = 2;
20250 14 goto switched;
20251 }
20252
20253 14 return true;
20254 }
20255
20256 case MSGC_GOTOIFCTRPC:
20257 {
20258 int32_t counter = args[0];
20259 int32_t amount = (int32_t)((args[1]/100)*game->get_maxcounter(counter));
20260
20261 if(game->get_counter(counter)>=amount)
20262 {
20263 last_arg = 2;
20264 goto switched;
20265 }
20266
20267 return true;
20268 }
20269
20270 case MSGC_GOTOIFTRICOUNT:
20271 {
20272 if(TriforceCount() >= args[0])
20273 {
20274 last_arg = 1;
20275 goto switched;
20276 }
20277
20278 return true;
20279 }
20280
20281 case MSGC_GOTOIFTRI:
20282 {
20283 int32_t lev = args[0];
20284
20285 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20286 {
20287 last_arg = 1;
20288 goto switched;
20289 }
20290
20291 return true;
20292 }
20293
20294 case MSGC_SETUPMENU:
20295 {
20296 5 msg_menu_data[MNU_CURSOR_TILE] = args[0];
20297 5 msg_menu_data[MNU_CURSOR_CSET] = args[1];
20298 5 msg_menu_data[MNU_CURSOR_WID] = args[2];
20299 5 msg_menu_data[MNU_CURSOR_HEI] = args[3];
20300 5 msg_menu_data[MNU_CURSOR_FLIP] = args[4];
20301 5 return true;
20302 }
20303
20304 case MSGC_MENUCHOICE:
20305 {
20306 18 int32_t pos = args[0];
20307 18 int32_t upos = args[1];
20308 18 int32_t dpos = args[2];
20309 18 int32_t lpos = args[3];
20310 18 int32_t rpos = args[4];
20311
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 2 times.
18 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20312 {
20313 2 ssc_tile_hei = ssc_tile_hei_buf;
20314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20315 2 ssc_tile_hei_buf = -1;
20316 2 cursor_y += thei + MsgStrings[msgstr].vspace;
20317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bottom_margin_clip()) break;
20318 2 cursor_x=msg_margins[left];
20319 2 }
20320
20321 36 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20322 18 upos, dpos, lpos, rpos);
20323
20324
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20325 18 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20326 18 return true;
20327 }
20328
20329 case MSGC_RUNMENU:
20330 {
20331 5 msg_menu_data[MNU_CHOSEN] = 0;
20332 5 msg_menu_data[MNU_CAN_CONFIRM] = 0;
20333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(menu_options.size() < 1)
20334 return true;
20335 5 do_run_menu = true;
20336 5 return true;
20337 }
20338
20339 case MSGC_GOTOMENUCHOICE:
20340 {
20341 7 int32_t choice = args[0];
20342
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(msg_menu_data[MNU_CHOSEN] == choice)
20343 {
20344 5 last_arg = 1;
20345 5 goto switched;
20346 }
20347
20348 2 return true;
20349 }
20350
20351 case MSGC_ENDSTRING:
20352 {
20353 3 do_end_str = true;
20354 3 return true;
20355 }
20356 case MSGC_WAIT_ADVANCE:
20357 {
20358 wait_advance = true;
20359 linkedmsgclk = 51;
20360 return true;
20361 }
20362 case MSGC_TRIGSECRETS:
20363 {
20364 bool perm = args[0];
20365 trigger_secrets_for_screen(TriggerSource::SCC, msgscr, false);
20366 if(perm)
20367 setmapflag(msgscr, mSECRET);
20368 return true;
20369 }
20370 case MSGC_TRIG_CMB_COPYCAT:
20371 {
20372 int copy_id = args[0];
20373 if(copy_id == byte(copy_id))
20374 trig_copycat(copy_id);
20375 return true;
20376 }
20377 case MSGC_SETSCREENSTATE:
20378 {
20379 int32_t flag = args[0];
20380 if(unsigned(flag)>=mMAXIND)
20381 {
20382 Z_error("SCC 133: Flag %d is invalid\n", flag);
20383 return true;
20384 }
20385 bool state = args[1];
20386 if(state)
20387 setmapflag(msgscr, 1<<flag);
20388 else
20389 unsetmapflag(msgscr, 1<<flag, true);
20390 return true;
20391 }
20392 case MSGC_SETSCREENSTATER:
20393 {
20394 int32_t map = args[0];
20395 int32_t scrid = args[1];
20396 if(map < 1 || map > map_count)
20397 {
20398 Z_error("SCC 134: Map %d is invalid\n", map);
20399 return true;
20400 }
20401 if(unsigned(scrid)>=0x80)
20402 {
20403 Z_error("SCC 134: Screen %d is invalid\n", scrid);
20404 return true;
20405 }
20406
20407 int32_t flag = args[2];
20408 if(unsigned(flag)>=mMAXIND)
20409 {
20410 Z_error("SCC 134: Flag %d is invalid\n", flag);
20411 return true;
20412 }
20413 bool state = args[3];
20414 if(state)
20415 setmapflag_mi(msgscr, mapind(map,scrid),1<<flag);
20416 else
20417 unsetmapflag_mi(msgscr, mapind(map,scrid),1<<flag,true);
20418 return true;
20419 }
20420 switched:
20421 55 int32_t lev = args[last_arg];
20422
3/4
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
55 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
20423
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 33 times.
54 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
20424 {
20425 setmsg(lev);
20426 }
20427 else
20428 {
20429 55 donewmsg(msgscr, lev);
20430 55 ssc_tile_hei_buf = -1;
20431 }
20432 55 putprices(false);
20433 55 return true;
20434 }
20435
20436 return false;
20437 3293 }
20438
20439 3299 static std::string parsemsgcode2(const StringCommand& command)
20440 {
20441
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (command.code == MSGC_NAME)
20442 {
20443
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 return game->get_name();
20444 }
20445 else
20446 {
20447 3293 parsemsgcode(command);
20448 }
20449
20450
1/2
✓ Branch 0 taken 3293 times.
✗ Branch 1 not taken.
3293 return "";
20451 3299 }
20452
20453 252636 static bool putmsgchar(bool play_sfx)
20454 {
20455 DCHECK(msg_it->state == MsgStr::iterator::CHARACTER);
20456 DCHECK(!msg_it->character.empty());
20457
20458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252636 times.
252636 if (bottom_margin_clip())
20459 return false;
20460
20461 // If the current word would overflow the margins, increment cursor to the next line.
20462 252636 const char* rem_word = msg_it->remaining_word();
20463 252636 int tlength = text_length(msgfont, rem_word) + ((int32_t)strlen(rem_word)*MsgStrings[msgstr].hspace);
20464
4/4
✓ Branch 0 taken 5669 times.
✓ Branch 1 taken 246967 times.
✓ Branch 2 taken 499 times.
✓ Branch 3 taken 5078 times.
258213 if (cursor_x+tlength > (msg_w-msg_margins[right]) &&
20465
4/4
✓ Branch 0 taken 5577 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 5078 times.
✓ Branch 3 taken 92 times.
5669 ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)) ? true : strcmp(rem_word," ")!=0))
20466 {
20467 5577 ssc_tile_hei = ssc_tile_hei_buf;
20468
1/2
✓ Branch 0 taken 5577 times.
✗ Branch 1 not taken.
5577 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20469 5577 ssc_tile_hei_buf = -1;
20470 5577 cursor_y += thei + MsgStrings[msgstr].vspace;
20471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5577 times.
5577 if (bottom_margin_clip()) return false;
20472
20473 5577 cursor_x = msg_margins[left];
20474 5577 }
20475
20476
2/2
✓ Branch 0 taken 34920 times.
✓ Branch 1 taken 217716 times.
252636 if (play_sfx)
20477 217716 sfx(MsgStrings[msgstr].sfx);
20478
20479 // Print the character (unless it's just a space).
20480
2/2
✓ Branch 0 taken 58964 times.
✓ Branch 1 taken 193672 times.
252636 if (msg_it->character != " ")
20481 193672 textout_styled_aligned_ex(msg_txt_bmp_buf, msgfont, msg_it->character.c_str(), cursor_x, cursor_y, msg_shdtype, sstaLEFT, msgcolour, msg_shdcol, -1);
20482
20483 // Move the cursor.
20484 252636 cursor_x += msgfont->vtable->text_length(msgfont, msg_it->character.c_str());
20485
2/2
✓ Branch 0 taken 58964 times.
✓ Branch 1 taken 193672 times.
252636 if (msg_it->character != " ")
20486 193672 cursor_x += MsgStrings[msgstr].hspace;
20487
20488 252636 return true;
20489 252636 }
20490
20491 enum msg_tick_result {msg_tick_exit, msg_tick_break, msg_tick_continue};
20492
20493 static void msg_tick_end(bool disappear = false);
20494 241733 static msg_tick_result msg_tick(bool play_sfx, bool burst_mode)
20495 {
20496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241733 times.
241733 if (msg_it->done())
20497 return msg_tick_exit;
20498
20499
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 239702 times.
241733 if (!do_run_menu)
20500 {
20501
4/4
✓ Branch 0 taken 239702 times.
✓ Branch 1 taken 3299 times.
✓ Branch 2 taken 3299 times.
✓ Branch 3 taken 239702 times.
243001 while (msg_it->state == MsgStr::iterator::COMMAND && !do_run_menu)
20502 {
20503 3299 bool one_frame_command_delay = !replay_version_check(41);
20504 3299 std::string text = parsemsgcode2(msg_it->command);
20505
2/2
✓ Branch 0 taken 3293 times.
✓ Branch 1 taken 6 times.
3299 if (text.empty())
20506 {
20507
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3293 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3293 times.
3293 msg_it->set_buffer("");
20508 // Advance the iterator to run many commands in one frame.
20509
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 3169 times.
3293 if (!one_frame_command_delay)
20510
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 msg_it->next();
20511 3293 }
20512 else
20513 {
20514
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 msg_it->set_buffer(text);
20515
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 msg_it->next();
20516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (one_frame_command_delay)
20517 6 msg_it->post_segment_delay = 1;
20518 }
20519 3299 }
20520
20521
2/2
✓ Branch 0 taken 3177 times.
✓ Branch 1 taken 236525 times.
239702 if (msg_it->state == MsgStr::iterator::CHARACTER)
20522 {
20523
1/2
✓ Branch 0 taken 236525 times.
✗ Branch 1 not taken.
236525 if (!putmsgchar(play_sfx)) return msg_tick_break;
20524 236525 }
20525 239702 }
20526
20527 241733 bool wait_advance_check_early = !burst_mode;
20528
20529
2/2
✓ Branch 0 taken 78489 times.
✓ Branch 1 taken 163244 times.
241733 if (wait_advance_check_early)
20530 {
20531
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 163243 times.
163244 if (do_end_str)
20532 {
20533 1 msg_tick_end();
20534 1 return msg_tick_exit;
20535 }
20536
20537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163243 times.
163243 if (wait_advance)
20538 {
20539 msg_it->next();
20540 return msg_tick_exit;
20541 }
20542 163243 }
20543
20544
2/2
✓ Branch 0 taken 239696 times.
✓ Branch 1 taken 2036 times.
241732 if (do_run_menu)
20545 {
20546
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2031 times.
2036 if (runMenuCursor())
20547 {
20548 5 do_run_menu = false;
20549
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if (!burst_mode)
20550 {
20551 2 msg_it->next();
20552 2 return msg_tick(play_sfx, burst_mode);
20553 }
20554 3 }
20555 2031 else return msg_tick_break;
20556 3 }
20557
20558 239699 msg_it->next();
20559
20560
2/2
✓ Branch 0 taken 161744 times.
✓ Branch 1 taken 77955 times.
239699 if (!wait_advance_check_early)
20561 {
20562
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 77953 times.
77955 if (do_end_str)
20563 {
20564 2 msg_tick_end();
20565 2 return msg_tick_exit;
20566 }
20567
20568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77953 times.
77953 if (wait_advance)
20569 return msg_tick_exit;
20570 77953 }
20571
20572
4/4
✓ Branch 0 taken 4006 times.
✓ Branch 1 taken 235691 times.
✓ Branch 2 taken 1988 times.
✓ Branch 3 taken 2018 times.
239697 if (msg_it->done() && MsgStrings[msgstr].nextstring)
20573 {
20574
1/2
✓ Branch 0 taken 2018 times.
✗ Branch 1 not taken.
2018 if (MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20575 setmsg(MsgStrings[msgstr].nextstring);
20576 2018 }
20577
20578 239697 return msg_tick_continue;
20579 241733 }
20580
20581 165531 static void msg_tick_end(bool disappear)
20582 {
20583
2/2
✓ Branch 0 taken 164518 times.
✓ Branch 1 taken 1013 times.
165531 if (disappear)
20584 1013 goto disappear;
20585
20586 // Done printing the string
20587
8/8
✓ Branch 0 taken 164515 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 163018 times.
✓ Branch 3 taken 1497 times.
✓ Branch 4 taken 158993 times.
✓ Branch 5 taken 4025 times.
✓ Branch 6 taken 158993 times.
✓ Branch 7 taken 4025 times.
164518 if (do_end_str || !do_run_menu && (msg_it->done() || bottom_margin_clip()) && !linkedmsgclk)
20588 {
20589
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 4025 times.
4028 if(!do_end_str)
20590 {
20591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4025 times.
4025 while (msg_it->state == MsgStr::iterator::COMMAND)
20592 {
20593 parsemsgcode2(msg_it->command);
20594 msg_it->next();
20595 }
20596 4025 }
20597
20598 // Go to next string, or make it disappear by going to string 0.
20599
5/6
✓ Branch 0 taken 2008 times.
✓ Branch 1 taken 2020 times.
✓ Branch 2 taken 994 times.
✓ Branch 3 taken 1014 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 994 times.
4028 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
20600 {
20601 3034 linkedmsgclk=do_end_str?1:51;
20602 3034 }
20603
20604
2/2
✓ Branch 0 taken 2008 times.
✓ Branch 1 taken 2020 times.
4028 if(MsgStrings[msgstr].nextstring==0)
20605 {
20606
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 994 times.
2008 if(!get_qr(qr_MSGDISAPPEAR))
20607 994 {
20608 disappear:
20609 2007 msg_active = false;
20610 2007 Hero.finishedmsg();
20611 2007 }
20612
20613
2/2
✓ Branch 0 taken 3008 times.
✓ Branch 1 taken 13 times.
3021 if(repaircharge)
20614 {
20615
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 game->change_drupy(-(cur_screen >= 128 ? special_warp_return_scr : msgscr)->catchall);
20616 13 repaircharge = 0;
20617 13 }
20618
20619
2/2
✓ Branch 0 taken 3019 times.
✓ Branch 1 taken 2 times.
3021 if(adjustmagic)
20620 {
20621
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_qr(qr_OLD_HALF_MAGIC))
20622 {
20623
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(game->get_magicdrainrate())
20624 2 game->set_magicdrainrate(1);
20625 2 }
20626 else if(game->get_magicdrainrate() > 1)
20627 {
20628 game->set_magicdrainrate(game->get_magicdrainrate()/2);
20629 }
20630 2 adjustmagic = false;
20631 2 sfx(WAV_SCALE);
20632
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20633 2 }
20634
20635
2/2
✓ Branch 0 taken 3019 times.
✓ Branch 1 taken 2 times.
3021 if(learnslash)
20636 {
20637 2 game->set_canslash(1);
20638 2 learnslash = false;
20639 2 sfx(WAV_SCALE);
20640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag(msgscr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20641 2 }
20642 3021 }
20643 5041 }
20644 165531 }
20645
20646 6225 static void msg_consume_spaces()
20647 {
20648
2/2
✓ Branch 0 taken 6225 times.
✓ Branch 1 taken 16111 times.
22336 while (msg_it->character == " ")
20649 {
20650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16111 times.
16111 if (!putmsgchar(false)) break;
20651
20652 // Advance the iterator.
20653 16111 msg_it->next();
20654
20655 // The "Continue From Previous" feature
20656
1/2
✓ Branch 0 taken 16111 times.
✗ Branch 1 not taken.
16111 if (msg_it->state == MsgStr::iterator::DONE)
20657 {
20658 if(MsgStrings[msgstr].nextstring)
20659 {
20660 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
20661 {
20662 setmsg(MsgStrings[msgstr].nextstring);
20663 }
20664 }
20665 }
20666 }
20667 6225 }
20668
20669 14596907 void putmsg()
20670 {
20671
2/2
✓ Branch 0 taken 681411 times.
✓ Branch 1 taken 13915496 times.
14596907 if(!msgorig) msgorig=msgstr;
20672
20673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14596907 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14596907 if(wait_advance && linkedmsgclk < 1)
20674 linkedmsgclk = 1;
20675
2/2
✓ Branch 0 taken 14318523 times.
✓ Branch 1 taken 278384 times.
14596907 if(linkedmsgclk>0)
20676 {
20677
2/2
✓ Branch 0 taken 126883 times.
✓ Branch 1 taken 151501 times.
278384 if(linkedmsgclk==1)
20678 {
20679
6/6
✓ Branch 0 taken 126880 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 123969 times.
✓ Branch 3 taken 2911 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 123851 times.
126883 if(do_end_str||cAbtn()||cBbtn())
20680 {
20681 3032 do_end_str = false;
20682 3032 linkedmsgclk = 0;
20683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3032 times.
3032 if(wait_advance)
20684 {
20685 wait_advance = false;
20686 }
20687 else
20688 {
20689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3032 times.
3032 if (!msgscr) msgscr = hero_scr;
20690 3032 msgstr=MsgStrings[msgstr].nextstring;
20691 3032 ssc_tile_hei_buf = -1;
20692
3/4
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2019 times.
✓ Branch 2 taken 1013 times.
✗ Branch 3 not taken.
3032 if(!msgstr && enqueued_str)
20693 {
20694 msgstr = enqueued_str;
20695 enqueued_str = 0;
20696 }
20697
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 2019 times.
3032 if(!msgstr)
20698 {
20699 1013 msgfont=get_zc_font(font_zfont);
20700
20701
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1009 times.
1013 if(msgscr->room!=rGRUMBLE)
20702 1009 blockpath=false;
20703
20704 1013 dismissmsg();
20705 1013 msg_tick_end(true);
20706 1013 return;
20707 }
20708
20709 2019 donewmsg(msgscr, msgstr);
20710 2019 putprices(false);
20711 }
20712 2019 }
20713 125870 }
20714 else
20715 {
20716 151501 --linkedmsgclk;
20717 }
20718 277371 }
20719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14595894 times.
14595894 if(wait_advance) return; //Waiting for buttonpress
20720
20721
9/10
✓ Branch 0 taken 14593945 times.
✓ Branch 1 taken 1949 times.
✓ Branch 2 taken 676488 times.
✓ Branch 3 taken 13917457 times.
✓ Branch 4 taken 263106 times.
✓ Branch 5 taken 413382 times.
✓ Branch 6 taken 259082 times.
✓ Branch 7 taken 4024 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 259082 times.
14595894 if(!do_run_menu && (!msgstr || !msg_it || msg_it->done() || bottom_margin_clip()))
20722 {
20723
2/2
✓ Branch 0 taken 13917457 times.
✓ Branch 1 taken 417406 times.
14334863 if(!msgstr)
20724 13917457 msgorig=0;
20725
20726 14334863 msg_active = false;
20727 14334863 msg_it.reset();
20728 14334863 return;
20729 }
20730
20731
1/2
✓ Branch 0 taken 261031 times.
✗ Branch 1 not taken.
261031 if (!msg_it)
20732 return;
20733
20734 261031 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
20735
20736
2/2
✓ Branch 0 taken 256983 times.
✓ Branch 1 taken 4048 times.
261031 if (msg_it->state == MsgStr::iterator::NOT_STARTED)
20737 {
20738 4048 msg_it->next();
20739 4048 msg_consume_spaces();
20740 4048 }
20741
20742 // If the player is holding down the B button, or if msgspeed is 0, process as many characters
20743 // as possible. This skips the character-by-character animation that usually renders a string
20744 // slowly over many frames.
20745
4/4
✓ Branch 0 taken 1381 times.
✓ Branch 1 taken 259650 times.
✓ Branch 2 taken 891 times.
✓ Branch 3 taken 258759 times.
261031 if ((cBbtn() && get_qr(qr_ALLOWMSGBYPASS)) || msgspeed == 0)
20746 {
20747
2/2
✓ Branch 0 taken 1274 times.
✓ Branch 1 taken 78499 times.
80225 while (!msg_it->done())
20748 {
20749
5/6
✓ Branch 0 taken 20654 times.
✓ Branch 1 taken 57845 times.
✓ Branch 2 taken 20644 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 20644 times.
✗ Branch 5 not taken.
78499 if (msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
20750 10 goto breakout; // break out if message speed was changed to non-zero
20751
20752 78489 auto tick = msg_tick(msg_it->character != " ", true);
20753
2/2
✓ Branch 0 taken 77955 times.
✓ Branch 1 taken 534 times.
78489 if (tick == msg_tick_break)
20754 534 break;
20755
2/2
✓ Branch 0 taken 77953 times.
✓ Branch 1 taken 2 times.
77955 if (tick == msg_tick_exit)
20756 2 return;
20757 }
20758
20759
2/2
✓ Branch 0 taken 534 times.
✓ Branch 1 taken 1274 times.
1808 if (!do_run_menu)
20760 {
20761 1274 msgclk = 72;
20762 1274 }
20763 1808 }
20764 else
20765 258759 {
20766 breakout:
20767 258769 word tempspeed = msgspeed;
20768
2/2
✓ Branch 0 taken 257806 times.
✓ Branch 1 taken 963 times.
258769 if (do_run_menu)
20769 963 tempspeed = 0;
20770
6/6
✓ Branch 0 taken 207564 times.
✓ Branch 1 taken 51205 times.
✓ Branch 2 taken 121557 times.
✓ Branch 3 taken 86007 times.
✓ Branch 4 taken 111503 times.
✓ Branch 5 taken 10054 times.
258769 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
20771 96061 return;
20772 }
20773
20774 // Process the next msg tick.
20775 // This will either print a single character, or process a single string command (with one
20776 // exception).
20777
3/4
✓ Branch 0 taken 163242 times.
✓ Branch 1 taken 1274 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 163242 times.
164516 if (!msg_it->done() && !bottom_margin_clip())
20778 {
20779 // This may run an additional tick in the case of a string menu finishing: the first
20780 // tick wraps up the menu, and then a second tick processes the next character or command.
20781 163242 auto tick = msg_tick(true, false);
20782
2/2
✓ Branch 0 taken 1497 times.
✓ Branch 1 taken 161745 times.
163242 if (tick == msg_tick_break)
20783 {
20784 1497 msg_tick_end();
20785 1497 return;
20786 }
20787
2/2
✓ Branch 0 taken 161744 times.
✓ Branch 1 taken 1 times.
161745 if (tick == msg_tick_exit)
20788 1 return;
20789
20790 // If the next two characters are spaces, consume all upcoming spaces now.
20791
13/20
✓ Branch 0 taken 2751 times.
✓ Branch 1 taken 158993 times.
✓ Branch 2 taken 158993 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26246 times.
✓ Branch 5 taken 132747 times.
✓ Branch 6 taken 26246 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 26246 times.
✓ Branch 10 taken 135498 times.
✓ Branch 11 taken 26246 times.
✓ Branch 12 taken 2751 times.
✓ Branch 13 taken 158993 times.
✓ Branch 14 taken 159567 times.
✓ Branch 15 taken 2177 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
187990 if (!msg_it->done() && msg_it->peek(0) == " " && msg_it->peek(1) == " ")
20792 2177 msg_consume_spaces();
20793 161744 }
20794
20795 163018 msg_tick_end();
20796 14596455 }
20797
20798 124886 int32_t message_more_y()
20799 {
20800 //Is the flag ticked, do we really want a message more y larger than 160?
20801
5/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 124858 times.
✓ Branch 2 taken 124886 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124858 times.
✓ Branch 5 taken 28 times.
124886 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
20802 124886 msgy+=playing_field_offset;
20803 124886 return msgy;
20804 }
20805
20806 /*** Collision detection & handling ***/
20807
20808 14284668 void clear_script_one_frame_conditions()
20809 {
20810
2/2
✓ Branch 0 taken 38828840 times.
✓ Branch 1 taken 14284668 times.
53113508 for(int32_t j=0; j<guys.Count(); j++)
20811 {
20812 38828840 enemy *e = (enemy*)guys.spr(j);
20813
2/2
✓ Branch 0 taken 660090280 times.
✓ Branch 1 taken 38828840 times.
698919120 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
20814 38828840 }
20815 14284668 }
20816
20817 4874266 void check_enemy_lweapon_collision(weapon *w)
20818 {
20819
8/8
✓ Branch 0 taken 4261066 times.
✓ Branch 1 taken 613200 times.
✓ Branch 2 taken 3267627 times.
✓ Branch 3 taken 993439 times.
✓ Branch 4 taken 3205485 times.
✓ Branch 5 taken 62142 times.
✓ Branch 6 taken 16738 times.
✓ Branch 7 taken 3188747 times.
4874266 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
20820 {
20821
2/2
✓ Branch 0 taken 3173031 times.
✓ Branch 1 taken 11185998 times.
14359029 for(int32_t j=0; j<guys.Count(); j++)
20822 {
20823 11185998 enemy *e = (enemy*)guys.spr(j);
20824
20825 11185998 bool didhit = e->hit(w);
20826 //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
20827 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
20828
2/2
✓ Branch 0 taken 10965361 times.
✓ Branch 1 taken 220637 times.
11185998 if(didhit)
20829 {
20830 // !(e->stunclk)
20831 220637 int32_t h = e->takehit(w);
20832
2/2
✓ Branch 0 taken 186850 times.
✓ Branch 1 taken 33787 times.
220637 if (h < 0) // hitby code
20833 {
20834 33787 int indx = Lwpns.find(w);
20835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33787 times.
33787 if(indx > -1)
20836 33787 e->hitby[HIT_BY_LWEAPON] = indx+1;
20837 33787 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
20838 33787 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
20839
2/2
✓ Branch 0 taken 31382 times.
✓ Branch 1 taken 2405 times.
33787 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
20840 2405 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
20841 33787 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
20842 33787 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
20843 //we may need to handle this in special cases. -Z
20844 // arrow item pierce flag, for example -Em
20845 33787 }
20846
20847
2/2
✓ Branch 0 taken 33787 times.
✓ Branch 1 taken 186850 times.
220637 if(h < 0) // hit, check if weapon is "out of pierces"
20848 33787 w->hit_pierce(e, h);
20849
2/2
✓ Branch 0 taken 176463 times.
✓ Branch 1 taken 10387 times.
186850 else if(h > 0) // blocked
20850 10387 w->onhit(false, e, h);
20851
2/2
✓ Branch 0 taken 217981 times.
✓ Branch 1 taken 2656 times.
220637 if(abs(h) == 2)
20852 2656 break; // some enemy classes force a weapon hitting them to "wait a frame"
20853 217981 }
20854
20855
2/2
✓ Branch 0 taken 11170282 times.
✓ Branch 1 taken 13060 times.
11183342 if(w->Dead())
20856 {
20857 13060 break;
20858 }
20859 11170282 }
20860
20861 // Item flags added in 2.55:
20862 // BRang/HShot/Arrows item_flag4 is "Pick up anything" (port of qr_BRANGPICKUP)
20863 // BRang/HShot item_flag5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
20864 // Arrows item_flag2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
20865 // -Em
20866
6/6
✓ Branch 0 taken 2734561 times.
✓ Branch 1 taken 454186 times.
✓ Branch 2 taken 2689875 times.
✓ Branch 3 taken 44686 times.
✓ Branch 4 taken 44438 times.
✓ Branch 5 taken 2645437 times.
3188747 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
20867 {
20868 543310 int32_t itype, pitem = w->parentitem;
20869
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 454186 times.
✓ Branch 2 taken 44438 times.
✓ Branch 3 taken 44686 times.
543310 switch(w->id)
20870 {
20871 454186 case wBrang: itype = itype_brang; break;
20872 44438 case wArrow: itype = itype_arrow; break;
20873 case wHookshot:
20874 44686 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
20875 44686 break;
20876 }
20877
2/2
✓ Branch 0 taken 538269 times.
✓ Branch 1 taken 5041 times.
543310 if(pitem < 0) pitem = current_item_id(itype);
20878
5/6
✓ Branch 0 taken 44686 times.
✓ Branch 1 taken 498624 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 44586 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
543310 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & item_flag9))
20879 { //Swap with item
20880 for(int32_t j=0; j<items.Count(); j++)
20881 {
20882 if(items.spr(j)->hit(w))
20883 {
20884 item *theItem = ((item*)items.spr(j));
20885 bool priced = theItem->PriceIndex >-1;
20886 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
20887 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20888 || (((itemsbuf[w->parentitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20889 {
20890 if(!Hero.switchhookclk)
20891 {
20892 hooked_comborpos = rpos_t::None;
20893 hooked_layerbits = 0;
20894 switching_object = theItem;
20895 theItem->switch_hooked = true;
20896 w->misc = 2;
20897 w->step = 0;
20898 theItem->clk2=256;
20899 Hero.doSwitchHook(game->get_switchhookstyle());
20900 if(QMisc.miscsfx[sfxSWITCHED])
20901 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
20902 }
20903 }
20904 }
20905 }
20906 }
20907
6/6
✓ Branch 0 taken 44438 times.
✓ Branch 1 taken 498872 times.
✓ Branch 2 taken 374558 times.
✓ Branch 3 taken 330120 times.
✓ Branch 4 taken 498872 times.
✓ Branch 5 taken 330120 times.
543310 else if((w->id==wArrow&&itemsbuf[pitem].flags & item_flag2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & item_flag5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
20908 {
20909
2/2
✓ Branch 0 taken 88779 times.
✓ Branch 1 taken 374558 times.
463337 for(int32_t j=0; j<items.Count(); j++)
20910 {
20911
2/2
✓ Branch 0 taken 83884 times.
✓ Branch 1 taken 4895 times.
88779 if(items.spr(j)->hit(w))
20912 {
20913 4895 item *theItem = ((item*)items.spr(j));
20914 4895 bool priced = theItem->PriceIndex >-1;
20915
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 4763 times.
4895 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
20916
5/8
✓ Branch 0 taken 4895 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4895 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3786 times.
✓ Branch 5 taken 1109 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2065 times.
6960 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20917
4/6
✓ Branch 0 taken 3174 times.
✓ Branch 1 taken 2065 times.
✓ Branch 2 taken 3174 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3174 times.
4895 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey))&& !priced)))
20918 {
20919
1/2
✓ Branch 0 taken 1721 times.
✗ Branch 1 not taken.
5851 if(itemsbuf[theItem->id].collect_script)
20920 {
20921 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
20922 }
20923
20924 1721 Hero.checkitems(j);
20925 1721 }
20926 4895 }
20927 88779 }
20928 374558 }
20929
2/2
✓ Branch 0 taken 15347 times.
✓ Branch 1 taken 153405 times.
828992 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
20930 {
20931
2/2
✓ Branch 0 taken 36900 times.
✓ Branch 1 taken 153405 times.
190305 for(int32_t j=0; j<items.Count(); j++)
20932 {
20933
2/2
✓ Branch 0 taken 28212 times.
✓ Branch 1 taken 8688 times.
36900 if(items.spr(j)->hit(w))
20934 {
20935 8688 item *theItem = ((item*)items.spr(j));
20936 8688 bool priced = theItem->PriceIndex >-1;
20937
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8681 times.
8688 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
20938
4/6
✓ Branch 0 taken 8688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8454 times.
✓ Branch 5 taken 234 times.
8688 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
20939
5/10
✓ Branch 0 taken 7273 times.
✓ Branch 1 taken 1181 times.
✓ Branch 2 taken 1415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1415 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1415 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
8688 || (((itemsbuf[pitem].flags & item_flag4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & item_flag7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
20940 {
20941 7273 int32_t pickup = theItem->pickup;
20942 7273 int32_t id2 = theItem->id;
20943 7273 int32_t pstr = theItem->pstring;
20944 7273 int32_t pstr_flags = theItem->pickup_string_flags;
20945
20946 7273 std::vector<int32_t> &ev = FFCore.eventData;
20947 7273 ev.clear();
20948 7273 ev.push_back(id2*10000);
20949 7273 ev.push_back(pickup*10000);
20950 7273 ev.push_back(pstr*10000);
20951 7273 ev.push_back(pstr_flags*10000);
20952 7273 ev.push_back(0);
20953 7273 ev.push_back(theItem->getUID());
20954 7273 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
20955 7273 ev.push_back(w->getUID());
20956
20957 7273 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
20958 7273 bool nullify = ev[4] != 0;
20959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7273 times.
7273 if(nullify) continue;
20960
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 6197 times.
7273 if(w->id == wBrang)
20961 {
20962 6197 w->onhit(false);
20963 6197 }
20964
20965
2/2
✓ Branch 0 taken 6775 times.
✓ Branch 1 taken 498 times.
7273 if(w->dragging==-1)
20966 {
20967 498 w->dead=1;
20968 498 theItem->clk2=256;
20969 498 w->dragging=j;
20970 498 theItem->is_dragged = true;
20971 498 }
20972 7273 }
20973 8688 }
20974 36900 }
20975 153405 }
20976 543310 }
20977 3188747 }
20978 4874266 }
20979 14282479 void check_collisions()
20980 {
20981
2/2
✓ Branch 0 taken 4874231 times.
✓ Branch 1 taken 14282479 times.
19156710 for(uint q = 0; q < Lwpns.Count(); ++q)
20982 4874231 check_enemy_lweapon_collision((weapon*)Lwpns.spr(q));
20983 14282479 }
20984
20985 14284668 void dragging_item()
20986 {
20987
2/2
✓ Branch 0 taken 4990577 times.
✓ Branch 1 taken 14284668 times.
19275245 for(int32_t i=0; i<Lwpns.Count(); i++)
20988 {
20989 4990577 weapon *w = (weapon*)Lwpns.spr(i);
20990
20991
4/4
✓ Branch 0 taken 4527805 times.
✓ Branch 1 taken 462772 times.
✓ Branch 2 taken 4835194 times.
✓ Branch 3 taken 155383 times.
4990577 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & item_flag5)//item_flag5 is a port for qr_Z3BRANG_HSHOT
20992 {
20993
3/4
✓ Branch 0 taken 7247 times.
✓ Branch 1 taken 148136 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7247 times.
155383 if(w->dragging>=0 && w->dragging<items.Count())
20994 {
20995 7247 item* dragItem = (item*)items.spr(w->dragging);
20996 7247 dragItem->x=w->x;
20997 7247 dragItem->y=w->y;
20998
20999 // Drag the Fairy enemy as well as the Fairy item
21000 7247 int32_t id = dragItem->id;
21001
21002
4/4
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 6828 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 15 times.
7247 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21003 {
21004 404 movefairynew2(w->x,w->y,*dragItem);
21005 404 }
21006 7247 }
21007 155383 }
21008 4990577 }
21009 14284668 }
21010
21011 57 int32_t more_carried_items(int screen)
21012 {
21013 57 int32_t hasmorecarries = 0;
21014
21015
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 57 times.
121 for(int32_t i=0; i<items.Count(); i++)
21016 {
21017 64 auto spr = (item*)items.spr(i);
21018
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 57 times.
64 if (spr->screen_spawned == screen && (spr->pickup & ipENEMY))
21019 {
21020 57 hasmorecarries++;
21021 57 }
21022 64 }
21023
21024 57 return hasmorecarries;
21025 }
21026
21027 36535 static int count_guys_from_screen(int screen)
21028 {
21029 36535 int count = 0;
21030
2/2
✓ Branch 0 taken 237871 times.
✓ Branch 1 taken 36535 times.
274406 for (int i=0; i < guys.Count(); i++)
21031 {
21032
2/2
✓ Branch 0 taken 36538 times.
✓ Branch 1 taken 201333 times.
237871 if (((enemy*)guys.spr(i))->screen_spawned == screen)
21033 201333 count += 1;
21034 237871 }
21035 36535 return count;
21036 }
21037
21038 // messy code to do the enemy-carrying-the-item thing
21039 14672596 static void roaming_item(mapscr* scr)
21040 {
21041 14672596 int screen = scr->screen;
21042 14672596 auto& state = get_screen_state(screen);
21043
4/4
✓ Branch 0 taken 14636123 times.
✓ Branch 1 taken 36473 times.
✓ Branch 2 taken 14636061 times.
✓ Branch 3 taken 36535 times.
14672596 if (!(state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::MustGiveToEnemy) || !state.loaded_enemies)
21044 14636061 return;
21045
21046 // All enemies already dead upon entering a room?
21047
1/2
✓ Branch 0 taken 36535 times.
✗ Branch 1 not taken.
36535 if (count_guys_from_screen(screen) == 0)
21048 {
21049 return;
21050 }
21051
21052 36535 int guycarryingitem = -1;
21053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84544 times.
84544 for(int32_t j=0; j<guys.Count(); j++)
21054 {
21055 84544 enemy* e = (enemy*)guys.spr(j);
21056
4/4
✓ Branch 0 taken 62850 times.
✓ Branch 1 taken 21694 times.
✓ Branch 2 taken 26315 times.
✓ Branch 3 taken 36535 times.
84544 if (e->screen_spawned == screen && e->itemguy)
21057 {
21058 36535 guycarryingitem=j;
21059 36535 break;
21060 }
21061 48009 }
21062
21063
2/2
✓ Branch 0 taken 36458 times.
✓ Branch 1 taken 77 times.
36535 if (state.item_state == ScreenItemState::MustGiveToEnemy)
21064 {
21065
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(guycarryingitem == -1) //This happens when "default enemies" such as
21066 {
21067 return; //eSHOOTFBALL are alive but enemies from the list
21068 } //are not. Defer to HeroClass::checkspecial().
21069
21070 77 int32_t Item=scr->item;
21071
21072 77 state.item_state = ScreenItemState::None;
21073
21074
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
21075 {
21076 154 auto [x, y] = translate_screen_coordinates_to_world(screen);
21077 218 additem(x,y,Item,ipENEMY+ipONETIME+ipBIGRANGE
21078
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 13 times.
77 + (((scr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21079 );
21080 77 ((item*)items.spr(items.Count() - 1))->screen_spawned = screen;
21081 77 state.item_state = ScreenItemState::CarriedByEnemy;
21082 77 }
21083 else
21084 {
21085 return;
21086 }
21087 77 }
21088
21089
2/2
✓ Branch 0 taken 46044 times.
✓ Branch 1 taken 36535 times.
82579 for(int32_t i=0; i<items.Count(); i++)
21090 {
21091
4/4
✓ Branch 0 taken 42433 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 5898 times.
✓ Branch 3 taken 36535 times.
46044 if(((item*)items.spr(i))->pickup&ipENEMY && ((item*)items.spr(i))->screen_spawned == screen)
21092 {
21093
2/2
✓ Branch 0 taken 22240 times.
✓ Branch 1 taken 14295 times.
36535 if(get_qr(qr_HIDECARRIEDITEMS))
21094 {
21095 22240 items.spr(i)->x = -128; // Awfully inelegant, innit?
21096 22240 items.spr(i)->y = -128;
21097 22240 }
21098
2/4
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14295 times.
14295 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21099 {
21100
1/2
✓ Branch 0 taken 14295 times.
✗ Branch 1 not taken.
14295 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21101 {
21102 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21103 {
21104 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21105 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21106 }
21107 else
21108 {
21109 if(guys.spr(guycarryingitem)->extend >= 3)
21110 {
21111 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21112 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21113 }
21114 else
21115 {
21116 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21117 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21118 }
21119 }
21120 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21121 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21122 }
21123 else
21124 {
21125 14295 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21126 14295 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21127 14295 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21128 }
21129 14295 }
21130 36535 }
21131 46044 }
21132 14672596 }
21133
21134 14284668 void roaming_item()
21135 {
21136 28957264 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
21137 14672596 roaming_item(scr);
21138 14672596 });
21139 14284668 }
21140
21141 bool enemy::IsBigAnim()
21142 {
21143 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21144 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21145 || anim == a4FRM8DIRB);
21146 }
21147 2404571 int32_t enemy::getFlashingCSet()
21148 {
21149 //Special cset for the dying sprite
21150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2404571 times.
2404571 if(dying)
21151 {
21152 if (!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading == fade_blue_poof)
21153 return wpnsbuf[spr_death].csets & 15;
21154 else
21155 return (((clk2 + 5) >> 1) & 3) + 6;
21156 }
21157
21158 //Normal cset
21159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2404571 times.
2404571 if (hclk <= 0)
21160 {
21161 //Special cset for the flashing animation
21162 if (flags & guy_flashing)
21163 return (frame & 3) + 6;
21164 return cs;
21165 }
21166
21167 //Hurt animations
21168
2/2
✓ Branch 0 taken 3888 times.
✓ Branch 1 taken 2400683 times.
2404571 if(family==eeGANON)
21169 3888 return (((hclk-1)>>1)&3)+6;
21170
4/4
✓ Branch 0 taken 2231268 times.
✓ Branch 1 taken 169415 times.
✓ Branch 2 taken 487138 times.
✓ Branch 3 taken 1744130 times.
2400683 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
21171 1744130 return (((hclk-1)>>1)&3)+6;
21172
21173 656553 return cs;
21174 2404571 }
21175
21176 81644428 bool enemy::is_hitflickerframe(bool olddrawing)
21177 {
21178
6/6
✓ Branch 0 taken 81615924 times.
✓ Branch 1 taken 28504 times.
✓ Branch 2 taken 3956167 times.
✓ Branch 3 taken 77659757 times.
✓ Branch 4 taken 3183476 times.
✓ Branch 5 taken 772691 times.
81644428 if (family == eeGANON || !hclk || !get_qr(qr_ENEMIESFLICKER))
21179 80871737 return false;
21180
21181
3/4
✓ Branch 0 taken 496051 times.
✓ Branch 1 taken 276640 times.
✓ Branch 2 taken 496051 times.
✗ Branch 3 not taken.
772691 if (!olddrawing && !getCanFlicker())
21182 return false;
21183
21184 772691 int32_t fr = game->get_spriteflickerspeed();
21185
1/2
✓ Branch 0 taken 772691 times.
✗ Branch 1 not taken.
772691 if (fr == 0)
21186 return true;
21187 772691 return frame % (fr * 2) < fr;
21188 81644428 }
21189
21190 const char *old_guy_string[OLDMAXGUYS] =
21191 {
21192 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
21193 // 020
21194 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
21195 // 025
21196 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
21197 // 030
21198 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
21199 // 035
21200 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
21201 // 040
21202 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
21203 // 045
21204 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
21205 // 050
21206 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
21207 // 055
21208 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
21209 // 060
21210 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
21211 // 065
21212 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
21213 // 070
21214 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
21215 // 075
21216 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
21217 // 080
21218 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
21219 // 085
21220 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
21221 // 090
21222 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
21223 // 095
21224 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
21225 // 100
21226 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
21227 // 105
21228 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
21229 // 110
21230 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
21231 // 115
21232 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
21233 // 120
21234 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
21235 // 125
21236 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
21237 // 130
21238 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
21239 // 135
21240 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
21241 // 140
21242 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
21243 // 145
21244 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
21245 // 150
21246 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
21247 // 155
21248 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
21249 // 160
21250 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
21251 // 165
21252 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
21253 // 170
21254 "Pols Voice (Magic)", "Pols Voice (Whistle)", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
21255 // 175
21256 "Grappler Bug (HP) ", "Grappler Bug (MP) "
21257 };
21258
21259 15687886 int32_t enemy::get_dmisc(byte index)
21260 {
21261
20/33
✓ Branch 0 taken 14611 times.
✓ Branch 1 taken 15885 times.
✓ Branch 2 taken 3236 times.
✓ Branch 3 taken 7390 times.
✓ Branch 4 taken 2144 times.
✓ Branch 5 taken 1794 times.
✓ Branch 6 taken 1051 times.
✓ Branch 7 taken 250 times.
✓ Branch 8 taken 1852 times.
✓ Branch 9 taken 1822 times.
✓ Branch 10 taken 7793452 times.
✓ Branch 11 taken 7597384 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 40 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 216 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 884 times.
✓ Branch 25 taken 1120 times.
✓ Branch 26 taken 331 times.
✓ Branch 27 taken 238061 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 6055 times.
✗ Branch 32 not taken.
15687886 switch (index)
21262 {
21263 14611 case 0: return dmisc1;
21264 15885 case 1: return dmisc2;
21265 3236 case 2: return dmisc3;
21266 7390 case 3: return dmisc4;
21267 2144 case 4: return dmisc5;
21268 1794 case 5: return dmisc6;
21269 1051 case 6: return dmisc7;
21270 250 case 7: return dmisc8;
21271 1852 case 8: return dmisc9;
21272 1822 case 9: return dmisc10;
21273 7793452 case 10: return dmisc11;
21274 7597384 case 11: return dmisc12;
21275 case 12: return dmisc13;
21276 308 case 13: return dmisc14;
21277 case 14: return dmisc15;
21278 40 case 15: return dmisc16;
21279 case 16: return dmisc17;
21280 216 case 17: return dmisc18;
21281 case 18: return dmisc19;
21282 case 19: return dmisc20;
21283 case 20: return dmisc21;
21284 case 21: return dmisc22;
21285 case 22: return dmisc23;
21286 case 23: return dmisc24;
21287 884 case 24: return dmisc25;
21288 1120 case 25: return dmisc26;
21289 331 case 26: return dmisc27;
21290 238061 case 27: return dmisc28;
21291 case 28: return dmisc29;
21292 case 29: return dmisc30;
21293 case 30: return dmisc31;
21294 6055 case 31: return dmisc32;
21295 }
21296
21297 return 0;
21298 15687886 }
21299
21300 312 void enemy::set_dmisc(byte index, int32_t value)
21301 {
21302
3/33
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 4 times.
✓ Branch 27 taken 24 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 284 times.
✗ Branch 32 not taken.
312 switch (index)
21303 {
21304 case 0: dmisc1 = value; break;
21305 case 1: dmisc2 = value; break;
21306 case 2: dmisc3 = value; break;
21307 case 3: dmisc4 = value; break;
21308 case 4: dmisc5 = value; break;
21309 case 5: dmisc6 = value; break;
21310 case 6: dmisc7 = value; break;
21311 case 7: dmisc8 = value; break;
21312 case 8: dmisc9 = value; break;
21313 case 9: dmisc10 = value; break;
21314 case 10: dmisc11 = value; break;
21315 case 11: dmisc12 = value; break;
21316 case 12: dmisc13 = value; break;
21317 case 13: dmisc14 = value; break;
21318 case 14: dmisc15 = value; break;
21319 case 15: dmisc16 = value; break;
21320 case 16: dmisc17 = value; break;
21321 case 17: dmisc18 = value; break;
21322 case 18: dmisc19 = value; break;
21323 case 19: dmisc20 = value; break;
21324 case 20: dmisc21 = value; break;
21325 case 21: dmisc22 = value; break;
21326 case 22: dmisc23 = value; break;
21327 case 23: dmisc24 = value; break;
21328 case 24: dmisc25 = value; break;
21329 case 25: dmisc26 = value; break;
21330 4 case 26: dmisc27 = value; break;
21331 24 case 27: dmisc28 = value; break;
21332 case 28: dmisc28 = value; break;
21333 case 29: dmisc30 = value; break;
21334 case 30: dmisc31 = value; break;
21335 284 case 31: dmisc32 = value; break;
21336 }
21337 312 }
21338